https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94809
Bug ID: 94809 Summary: Different results between gcc-9 and gcc-6 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: k.even-mendoza at imperial dot ac.uk Target Milestone: --- Seen on: 18.04.4 LTS kar@kar-VirtualBox:~/ex1$ gcc-9 ex2.c -o ex kar@kar-VirtualBox:~/ex1$ ./ex 0 kar@kar-VirtualBox:~/ex1$ gcc-6 ex2.c -o ex kar@kar-VirtualBox:~/ex1$ ./ex 1 kar@kar-VirtualBox:~/ex1$ more ex2.c #include <stdio.h> int main() { int a = 0; unsigned long long one = 1; ((18446744073709551615UL / one) < a++, one); printf("%d\n", a); } === 1. Output shall be 1 instead of 0. 2. GCC-7, GCC-8, GCC-9 and HEAD 562bfb1 produce 0. gcc-9 (Ubuntu 9.2.1-17ubuntu1~18.04.1) 9.2.1 20191102 gcc-8 (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0 gcc-7 (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 gcc-6 (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026 compiled: gcc-9 ex2.c -o ex 3. Explanation: ((18446744073709551615UL / one) < a++, one); the part before "," is skipped including the increase of "a" by "1" (a++). As a result the printf outputs 0 instead of 1. 4. GCC-6 and LLVM (for example) produce 1. Note: You can try to compile the code with GCC-6 or llvm to observe the behaviour where the output is 1.