Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You can enable this in GCC on a compilation unit basis with `-fsanitize=signed-integer-overflow`. In combination with `-fsanitize-undefined-trap-on-error`, the checks are quite cheap (on x86, usually just a `jo` to a `ud2` instruction).

(Note that while `-ftrapv` would seem equivalent, I've found it to be less reliable, particularly with compile-time checking.)



And clang!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: