Skip to content

Commit 6bc45c0

Browse files
committed
test: avoid division by zero
If the test is invoked with and empty argument array, we would use 0 (`argc`) as divisior in a test-division. Avoid this and use a divisor that is never 0. This also fixes a test-failure in a later `builtin_constant_p()` test that righfully assumes that `non_constant_expr` cannot be 0 given that it was used as divisor before. Reported-by: ms178 <[email protected]> Signed-off-by: David Rheinsberg <[email protected]>
1 parent 1f8d194 commit 6bc45c0

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
@@ -503,7 +503,7 @@ static void test_basic_gnuc(int non_constant_expr) {
503503
c_assert(foo == 11);
504504

505505
c_assert(__builtin_constant_p(c_div_round_up(1, 5)));
506-
c_assert(!__builtin_constant_p(c_div_round_up(1, non_constant_expr)));
506+
c_assert(!__builtin_constant_p(c_div_round_up(8, 1 + !non_constant_expr)));
507507

508508
/* alternative calculation is [(x + y - 1) / y], but it may overflow */
509509
for (i = 0; i <= 0xffff; ++i) {

0 commit comments

Comments
 (0)