public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/111151] New: [12/13/14 Regression] Wrong code at -O0 on x86_64-pc-linux-gnu
@ 2023-08-25  6:39 jwzeng at nuaa dot edu.cn
  2023-08-25  7:16 ` [Bug middle-end/111151] " rguenth at gcc dot gnu.org
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: jwzeng at nuaa dot edu.cn @ 2023-08-25  6:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111151
           Summary: [12/13/14 Regression] Wrong code at -O0 on
                    x86_64-pc-linux-gnu
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jwzeng at nuaa dot edu.cn
  Target Milestone: ---

Link to the Compiler Explorer: https://godbolt.org/z/MY4Er6b3e

The following code snippet, gcc at -O0 produces the wrong code. I also compiled
this code with almost all versions up to and including gcc-13 and got the same
error.

$ cat test.c
int printf(const char *, ...);
short t = -32166;
unsigned long long int a, b, c;
int main()
{
    a = 32739 > t + 4503599ULL ? 32739 : t + 4503599ULL;
    b = -10 * a;
    printf("%llu (Split calculation result)\n", b);
    c = -10 * (32739 > t + 4503599ULL ? 32739 : t + 4503599ULL);
    printf("%llu (Combine calculation result)\n", c);
}
$
$ gcc-tk test.c; ./a.out
18446744073664837286 (Split calculation result)
18446744073709224226 (Combine calculation result)
$
$ clang-tk test.c; ./a.out
18446744073664837286 (Split calculation result)
18446744073664837286 (Combine calculation result)
$
$ ccomp test.c; ./a.out
18446744073664837286 (Split calculation result)
18446744073664837286 (Combine calculation result)
$
$ gcc-tk --version
gcc (GCC) 14.0.0 20230823 (experimental) [master r14-3395-g6cd8527307]
$
$ clang-tk --version
Ubuntu clang version 18.0.0
(++20230821052626+634b2fd2cac2-1~exp1~20230821172748.738)
$
$ ccomp --version
The CompCert C verified compiler, version 3.12

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

end of thread, other threads:[~2024-03-30  3:55 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-25  6:39 [Bug middle-end/111151] New: [12/13/14 Regression] Wrong code at -O0 on x86_64-pc-linux-gnu jwzeng at nuaa dot edu.cn
2023-08-25  7:16 ` [Bug middle-end/111151] " rguenth at gcc dot gnu.org
2023-08-25  7:16 ` rguenth at gcc dot gnu.org
2023-08-25 11:51 ` mikpelinux at gmail dot com
2023-08-25 12:27 ` rguenth at gcc dot gnu.org
2023-08-25 12:28 ` rguenth at gcc dot gnu.org
2023-08-25 12:35 ` rguenth at gcc dot gnu.org
2023-08-26  3:27 ` pinskia at gcc dot gnu.org
2024-03-22 13:40 ` law at gcc dot gnu.org
2024-03-22 17:29 ` jakub at gcc dot gnu.org
2024-03-22 17:37 ` jakub at gcc dot gnu.org
2024-03-22 17:41 ` jakub at gcc dot gnu.org
2024-03-22 17:57 ` jakub at gcc dot gnu.org
2024-03-22 18:48 ` jakub at gcc dot gnu.org
2024-03-22 19:15 ` jakub at gcc dot gnu.org
2024-03-25  7:23 ` rguenth at gcc dot gnu.org
2024-03-25 11:01 ` jakub at gcc dot gnu.org
2024-03-25 12:45 ` rguenth at gcc dot gnu.org
2024-03-26 10:22 ` cvs-commit at gcc dot gnu.org
2024-03-26 10:32 ` [Bug middle-end/111151] [12/13 " jakub at gcc dot gnu.org
2024-03-26 15:43 ` cvs-commit at gcc dot gnu.org
2024-03-30  3:55 ` cvs-commit 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).