Hi: When compiling following C program:
#include <stdio.h> int main(int argc, char ** argv) { volatile unsigned long long a = 0; volatile unsigned long long b = a + (1ULL << 63); if (((long long) a - (long long) b) >= 0) printf("wrong\n"); else printf("right\n"); return 0; } with mingw gcc compiler: /home/johannes/.zeranoe/mingw-w64/x86_64/bin/x86_64-w64-mingw32-gcc --version x86_64-w64-mingw32-gcc (GCC) 12.3.1 20230814 and -O2 the output of the program is: wrong When compiling without -O2 or compiling on another gcc (the one that comes with Linux Ubuntu for example) the result is: right Is the above comparision in the C program something that is undefined? Looking at the assembly code the difference seems to be the conditional jump expression: it is js .L4 in the right case and jl .L4 in the wrong case. My 8086 assembly is almost about 35-40 years old, however I recall that jl jumps if operand 2 is less than operand 1 (in System-V syntax ...). Is this maybe a mingw gcc bug? Thanks a lot for looking into this, and best regards, - Johannes _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public