https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96549
Bug ID: 96549 Summary: Wrong evaluation of a comparison between long & short Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: zhige.yu18 at imperial dot ac.uk Target Milestone: --- The following code snippet: #include <stdio.h> long c = -1L; long b = 0L; int main(void) { if (3L > (short) ((c ^= (b = 1L)) * 3L)) printf("hello "); printf("world!\n"); } > $ /usr/gcc-trunk/bin/gcc -O0 bug.c -o a.out; ./a.out > world! > $ clang-10 -O0 bug.c -o a.out; ./a.out > hello world! When compiled with -O0/1/2/3, GCC omits the then-branch of the if-statement, and prints "world!" only. This bug can be found in GCC-10.2.0 and GCC-11.0.0 20200804 (experimental). GCC-9.3.0 and earlier versions of GCC do not have this bug.