public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111210] New: Wrong code at -Os on x86_64-linux-gnu since r12-4849-gf19791565d7
@ 2023-08-28  7:13 shaohua.li at inf dot ethz.ch
  2023-08-28  7:29 ` [Bug c/111210] " amonakov at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-08-28  7:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111210
           Summary: Wrong code at -Os on x86_64-linux-gnu since
                    r12-4849-gf19791565d7
           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
  Target Milestone: ---

gcc at -Os produces the wrong code.

Bisected to r12-4849-gf19791565d7

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

$ cat a.c
int printf(const char *, ...);
int a;
int *b = &a;
int c(long *d) {
  if (*d)
    return *(int *)0;
  return *(int *)(d + 1);
}
int main() {
  long e[] = {0, 100};
  int f = c(e);
  *b = f;
  printf("%d\n", a);
}
$
$ gcc -O3 a.c && ./a.out
100
$ gcc -Os a.c && ./a.out
0
$

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

end of thread, other threads:[~2023-08-28 12:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28  7:13 [Bug c/111210] New: Wrong code at -Os on x86_64-linux-gnu since r12-4849-gf19791565d7 shaohua.li at inf dot ethz.ch
2023-08-28  7:29 ` [Bug c/111210] " amonakov at gcc dot gnu.org
2023-08-28 12:46 ` shaohua.li at inf dot ethz.ch
2023-08-28 12:50 ` xry111 at gcc dot gnu.org
2023-08-28 12:55 ` amonakov at gcc dot gnu.org
2023-08-28 12:58 ` shaohua.li at inf dot ethz.ch

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).