public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since
@ 2023-09-19  7:38 shaohua.li at inf dot ethz.ch
  2023-09-19  7:45 ` [Bug tree-optimization/111472] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836 xry111 at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-09-19  7:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111472
           Summary: Wrong code at -Os on x86_64-linux-gnu since
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shaohua.li at inf dot ethz.ch
                CC: amacleod at redhat dot com
  Target Milestone: ---

gcc at -Os produced the wrong code.

Bisected to r11-4563-gd0d8b5d836

Compiler explorer: https://godbolt.org/z/EPznGbaje

With -fwrapv the issue goes away.

$ cat a.c
int printf(const char *, ...);
int a, b, e, f;
short c = -1, i;
char g;
int h[4][1] = {8, 5, 8, 5};
int main() {
  int *j = &e, *k = &f;
  unsigned short d = c;
  i = d >> b;
  *j = i;
  g = 0;
  for (; g <= 3; g++)
    *k = h[(unsigned char)(1 + e) + g][0];
  printf("%d\n", f);
}
$
$ gcc -O0 a.c && ./a.out
5
$ gcc -Os a.c && ./a.out
Segmentation fault
$
$ gcc -fsanitize=undefined a.c && ./a.out
5
$

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

end of thread, other threads:[~2024-05-08 12:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19  7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
2023-09-19  7:45 ` [Bug tree-optimization/111472] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836 xry111 at gcc dot gnu.org
2023-09-19  7:47 ` shaohua.li at inf dot ethz.ch
2023-09-19  7:48 ` [Bug tree-optimization/111472] [11/12/13/14 Regression] " xry111 at gcc dot gnu.org
2023-09-19  7:48 ` pinskia at gcc dot gnu.org
2023-11-06 20:31 ` amacleod at redhat dot com
2023-11-06 20:35 ` amacleod at redhat dot com
2023-11-06 20:37 ` pinskia at gcc dot gnu.org
2024-03-07 22:24 ` [Bug tree-optimization/111472] [11/12/13 " law at gcc dot gnu.org
2024-05-08 12:15 ` [Bug tree-optimization/111472] [11 " rguenth 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).