Skip to content

Commit adc78dd

Browse files
nikicdvdhrm
authored andcommitted
Fix incorrect __builtin_constant_p test for c_align_to
16 aligned to 8 or 16 will always be 16, so it is legal for __builtin_constant_p to return true here, and Clang indeed performs this optimization (while GCC does not). Adjust the argument to 8, in which case the result of the expression is not a known constant. Signed-off-by: David Rheinsberg <[email protected]>
1 parent 6212139 commit adc78dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/test-basic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static void test_basic_gnuc(int non_constant_expr) {
545545
c_assert(__builtin_constant_p(c_align_to(16, 8)));
546546
c_assert(!__builtin_constant_p(c_align_to(non_constant_expr, 8)));
547547
c_assert(!__builtin_constant_p(c_align_to(16, non_constant_expr)));
548-
c_assert(!__builtin_constant_p(c_align_to(16, non_constant_expr ? 8 : 16)));
548+
c_assert(!__builtin_constant_p(c_align_to(8, non_constant_expr ? 8 : 16)));
549549
c_assert(__builtin_constant_p(c_align_to(16, 7 + 1)));
550550
c_assert(c_align_to(15, non_constant_expr ? 8 : 16) == 16);
551551
}

0 commit comments

Comments
 (0)