public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112996] New: Improperly evaluated value of the s390x conditional expression
@ 2023-12-13  7:04 22s302h0659 at sonline20 dot sen.go.kr
  2023-12-13  8:27 ` [Bug target/112996] " rguenth at gcc dot gnu.org
  2023-12-13 18:15 ` krebbel at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: 22s302h0659 at sonline20 dot sen.go.kr @ 2023-12-13  7:04 UTC (permalink / raw)
  To: gcc-bugs

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
```

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/112996] Improperly evaluated value of the s390x conditional expression
  2023-12-13  7:04 [Bug c/112996] New: Improperly evaluated value of the s390x conditional expression 22s302h0659 at sonline20 dot sen.go.kr
@ 2023-12-13  8:27 ` rguenth at gcc dot gnu.org
  2023-12-13 18:15 ` krebbel at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-12-13  8:27 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |krebbel at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I wonder if anybody from the s390 folks could have a look at this (and similar
bugs filed throughout the year).  Is anybody monitoring s390 target bugs?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/112996] Improperly evaluated value of the s390x conditional expression
  2023-12-13  7:04 [Bug c/112996] New: Improperly evaluated value of the s390x conditional expression 22s302h0659 at sonline20 dot sen.go.kr
  2023-12-13  8:27 ` [Bug target/112996] " rguenth at gcc dot gnu.org
@ 2023-12-13 18:15 ` krebbel at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: krebbel at gcc dot gnu.org @ 2023-12-13 18:15 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Krebbel <krebbel at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |iii at linux dot ibm.com
         Resolution|---                         |DUPLICATE

--- Comment #2 from Andreas Krebbel <krebbel at gcc dot gnu.org> ---
Same as with PR112986. Confirmed with qemu. Runs fine on real hardware.

*** This bug has been marked as a duplicate of bug 112986 ***

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-13 18:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13  7:04 [Bug c/112996] New: Improperly evaluated value of the s390x conditional expression 22s302h0659 at sonline20 dot sen.go.kr
2023-12-13  8:27 ` [Bug target/112996] " rguenth at gcc dot gnu.org
2023-12-13 18:15 ` krebbel at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).