public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111583] New: [13/14 Regression] Wrong code at -Os on x86_64-linux-gnu since r13-3281-g6cc3394507
@ 2023-09-25  7:24 shaohua.li at inf dot ethz.ch
  2023-09-25  7:27 ` [Bug tree-optimization/111583] " pinskia 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-25  7:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111583
           Summary: [13/14 Regression] Wrong code at -Os on
                    x86_64-linux-gnu since r13-3281-g6cc3394507
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          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 r13-3281-g6cc3394507

Compiler explorer: https://godbolt.org/z/8GM9YvMKb

$ cat a.c
int printf(const char *, ...);
int b, c, d;
char e;
short f;
const unsigned short **g;
char h(char k) {
  if (k)
    return '0';
  return 0;
}
int l() {
  b = 0;
  return 1;
}
static short m(unsigned k) {
  const unsigned short *n[65];
  g = &n[4];
  k || l();
  long a = k;
  char i = 0;
  unsigned long j = k;
  while (j--)
    *(char *)a++ = i;
  c = h(d);
  f = k;
  return 0;
}
int main() {
  long o = (e < 0) << 5;
  m(o);
  printf("%d\n", f);
}
$
$ gcc -O0 -fsanitize=address,undefined a.c && ./a.out
0
$ gcc -Os a.c && ./a.out
32
$

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

end of thread, other threads:[~2023-11-10 14:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-25  7:24 [Bug tree-optimization/111583] New: [13/14 Regression] Wrong code at -Os on x86_64-linux-gnu since r13-3281-g6cc3394507 shaohua.li at inf dot ethz.ch
2023-09-25  7:27 ` [Bug tree-optimization/111583] " pinskia at gcc dot gnu.org
2023-09-25  7:46 ` pinskia at gcc dot gnu.org
2023-09-28 15:17 ` pinskia at gcc dot gnu.org
2023-09-29  9:05 ` rguenth at gcc dot gnu.org
2023-09-29  9:50 ` cvs-commit at gcc dot gnu.org
2023-09-29 10:02 ` [Bug tree-optimization/111583] [13 " rguenth at gcc dot gnu.org
2023-09-29 10:02 ` rguenth at gcc dot gnu.org
2023-11-10 14:24 ` cvs-commit at gcc dot gnu.org
2023-11-10 14:27 ` 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).