public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "shaohua.li at inf dot ethz.ch" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111422] New: Wrong code at -O3 on x86_64-linux-gnu Date: Fri, 15 Sep 2023 07:42:05 +0000 [thread overview] Message-ID: <bug-111422-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111422 Bug ID: 111422 Summary: Wrong code at -O3 on x86_64-linux-gnu Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch Target Milestone: --- gcc at -O3 produced the wrong code. Compiler explorer: https://godbolt.org/z/3b4v478TG $ cat a.c int printf(const char *, ...); int a, b; int *c = &b; unsigned d; char e; int f=1; int i(int k, char *l) { if (k < 6) return a; l[0] = l[1] = l[k - 1] = 8; return 0; } int m(int k) { char g[11]; int h = i(k, g); return h; } int main() { for (; b < 8; b = b + 1) ; int j; int *n[8]; j = 0; for (;18446744073709551608U + m(*c) + *c + j < 2; j++){ n[j] = &f; } for (; e <= 4; e++) d = *n[0] == f; printf("%d\n", d); } $ $ gcc -O0 a.c && ./a.out 1 $ gcc -O3 a.c && ./a.out Segmentation fault $ gcc -O3 -fwrapv a.c && ./a.out Segmentation fault $ gcc -fsanitize=address,undefined a.c && ./a.out 1 $
next reply other threads:[~2023-09-15 7:42 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-15 7:42 shaohua.li at inf dot ethz.ch [this message] 2023-09-15 12:20 ` [Bug tree-optimization/111422] " rguenth at gcc dot gnu.org 2023-09-15 12:26 ` rguenth at gcc dot gnu.org 2023-09-15 12:35 ` rguenth at gcc dot gnu.org 2024-01-16 10:51 ` [Bug middle-end/111422] " cvs-commit at gcc dot gnu.org 2024-03-02 0:38 ` cvs-commit at gcc dot gnu.org 2024-05-15 16:13 ` cvs-commit at gcc dot gnu.org 2024-06-11 10:36 ` cvs-commit at gcc dot gnu.org 2024-06-20 13:22 ` cvs-commit at gcc dot gnu.org 2024-06-20 13:27 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-111422-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).