https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #64 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The X + 100 > X case is optimized with: /* X + Y < Y is the same as X < 0 when there is no overflow. */ (for op (lt le gt ge) (simplify (op:c (plus:c@2 @0 @1) @1) (if (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0)) && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)) && !TYPE_OVERFLOW_SANITIZED (TREE_TYPE (@0)) && (CONSTANT_CLASS_P (@0) || single_use (@2))) (op @0 { build_zero_cst (TREE_TYPE (@0)); })))) So, if we wanted to maintain -Wstrict-overflow=*, we'd need to add it to this spot and to other 40+ or so other spots that check for TYPE_OVERFLOW_UNDEFINED. In this particular case, it would need to differentiate between whether @0 is a constant (then it should warn at WARN_STRICT_OVERFLOW_ALL level), or not, then it should warn at WARN_STRICT_OVERFLOW_COMPARISON level). Though, -fsanitize=undefined really is the preferred way how to check code, warnings will necessarily have lots of false positives, while the X + 100 > X case when written that way is easy to avoid, if it is e.g. after inlining it might not be that easy and there can be much more complex cases.