]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Prevent an implicit int promotion in malloc/tst-alloc_buffer.c
authorTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Mon, 26 Jun 2017 12:55:41 +0000 (09:55 -0300)
committerTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Mon, 26 Jun 2017 12:56:26 +0000 (09:56 -0300)
According to ISO C11, section 6.5.3.3 "Unary arithmetic operators", the
result of the ~ operator is the bitwise complement of its (promoted)
operand.
This can lead to a comparison of a char with another integer type.

Tested on powerpc, powerpc64 and powerpc64le.

* malloc/tst-alloc_buffer.c (test_misaligned): Cast to char
before comparing with another char.

ChangeLog
malloc/tst-alloc_buffer.c

index b213e7c4930aac03f59071757e797be58d485b3e..9e19f62d9d79aa61a844203c46cd84c5ba74daa5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-26  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
+
+       * malloc/tst-alloc_buffer.c (test_misaligned): Cast to char
+       before comparing with another char.
+
 2017-06-25  Rical Jasan  <ricaljasan@pacific.net>
 
        * manual/math.texi: Fix a grammatical error.
index 1c143999c70180f7586c17cbf476e76eed9d4d81..9b2bd2046a12c0f2e19f006009174cc74c4c0e08 100644 (file)
@@ -429,7 +429,7 @@ test_misaligned (char pad)
   }
 
   /* Verify that padding was not overwritten.  */
-  TEST_VERIFY (backing[0] == ~pad);
+  TEST_VERIFY (backing[0] == (char) ~pad);
   TEST_VERIFY (backing[SIZE + 1] == pad);
   free (backing);
 }