1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

Prevent an implicit int promotion in malloc/tst-alloc_buffer.c

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.
This commit is contained in:
Tulio Magno Quites Machado Filho
2017-06-26 09:55:41 -03:00
parent d9660db223
commit d54bb9b1d3
2 changed files with 6 additions and 1 deletions

View 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);
}