boostorg / wave

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

Fix checks for signed overflow #207

Closed jefftrull closed 3 months ago

jefftrull commented 8 months ago

When verifying that code being preprocessed does not invoke undefined behavior, Wave does it itself. This change performs tests on the operands in advance, instead.

Tests t_6_15, t_6_17, and t_6_18 (though not t_6_17, for some reason) signal errors in the absence of this fix with -fsanitize=signed-integer-overflow configured, but it does not cause the tests to fail, because these tests are expected to exit with an error anyway.

If merged, this will fix #197

jefftrull commented 3 months ago

While reviewing this old PR I realized that we don't handle INT_MIN / -1 properly so I've added that.