boostorg / wave

Boost.org wave module
http://boost.org/libs/wave
21 stars 49 forks source link

Test for signed overflow occurs after UB invoked #197

Closed jefftrull closed 3 months ago

jefftrull commented 8 months ago

I noticed a warning in CI today for two lines in cpp_expression_value.hpp:

warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false

It looks like we perform the calculation, and then check to see if an overflow resulted. The compiler may discard the check (or worse).

jefftrull commented 8 months ago

Note: I only see this warning in gcc version 7 and before. The release notes for gcc 8 quietly note that -Wstrict-overflow is deprecated, although the documentation still lists it today, years later. At any rate the warning seems correct.

jefftrull commented 8 months ago

Running the unit tests when compiled with -fsanitize=signed-integer-overflow will cause two failures

jefftrull commented 8 months ago

Correction: three failures under gcc, four under Clang, thanks to what seems to be a gcc bug. However, it's basically invisible because these tests (t_6_015 through t_6_018) are supposed to fail anyway.