Skip to content

Commit

Permalink
Fix UB in test_types
Browse files Browse the repository at this point in the history
Fix (actually, supress) UB in test_types by disabling tests
that cause float-to-long cast
  • Loading branch information
p-senichenkov committed Nov 28, 2024
1 parent edee113 commit 02508e9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/tests/test_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,16 @@ TYPED_TEST(TestNumeric, Pow) {

test(0, 100);
test(22, 12);
test(123, 321);
test(Type(2.72), Type(1.3123141));
test(-102, 11);
test(-123, 123);
// 123^321 won't fit into long (i. e. IntType) -- it's UB
if constexpr (!std::is_same_v<Type, long>) {
test(123, 321);
}
test(Type(2.72), 1.3123141);
// -102^11 and -123^123 won't fit into long (i. e. IntType) -- it's UB
if constexpr (!std::is_same_v<Type, long>) {
test(-102, 11);
test(-123, 123);
}
test(-21, -7);
}

Expand Down

0 comments on commit 02508e9

Please sign in to comment.