[Bug c/91373] gcc6.2.0: ((U32)((U16 * U16)) >> 31) cannot always get correct result with gcc -O2

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Aug 6 07:39:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91373

--- Comment #5 from Marc Glisse <glisse at gcc dot gnu.org> ---
Note that gcc (like clang) provides a tool to help you detect this kind of
issue. If you compile with -fsanitize=undefined, then at runtime you will see:
main.c:7:20: runtime error: signed integer overflow: 63139 * 36032 cannot be
represented in type 'int'


More information about the Gcc-bugs mailing list