https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112996
Bug ID: 112996 Summary: Improperly evaluated value of the s390x conditional expression Product: gcc Version: 11.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: 22s302h0659 at sonline20 dot sen.go.kr Target Milestone: --- # Environment - Compiler: s390x-linux-gnu-gcc (64bit) - Version: gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) - Platform: Windows 11_5.15.90.1-microsoft-standard-WSL2 - Build Optimization Options: O0, O1, O2, O3 I installed the s390x-linux-gnu toolchain using the 'apt' package manager in Ubuntu and utilized s390x-linux-gnu-gcc (version 11.4.0) from it. # build script & excution script ```c s390x-linux-gnu-gcc -o bug0 bug.c -O0 -fsanitize=undefined s390x-linux-gnu-gcc -o bug1 bug.c -O1 -fsanitize=undefined s390x-linux-gnu-gcc -o bug2 bug.c -O2 -fsanitize=undefined s390x-linux-gnu-gcc -o bug3 bug.c -O3 -fsanitize=undefined ``` ```c qemu-s390x-static -L /usr/s390x-linux-gnu/ ./bug0 qemu-s390x-static -L /usr/s390x-linux-gnu/ ./bug1 qemu-s390x-static -L /usr/s390x-linux-gnu/ ./bug2 qemu-s390x-static -L /usr/s390x-linux-gnu/ ./bug3 ``` This is the build script and the execution script. # Source Code ```c #include <stdio.h> signed short v1 = 1; signed int v2 = 2; unsigned long long bug = 0; int main () { if ((v1 < v2)) { bug = v2; } printf("bug = %llu\n", bug); return 0; } ``` The C code built with GCC on the s390x architecture returns incorrect values. The evaluated value of the conditional expression in the 'if' statement should be true, but with the O2 and O3 options, it returns false. # output ```c Expected output O0: 2 O1: 2 O2: 2 O3: 2 Actual output O0: 2 O1: 2 O2: 0 O3: 0 ```