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

            Bug ID: 111445
           Summary: Wrong code at -Os on x86_64-linux-gnu since
                    r12-1077-g57bf3751511
           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
                CC: aldyh at redhat dot com
  Target Milestone: ---

gcc at -Os produced the wrong code

Bisected to r12-1077-g57bf3751511

Compiler explorer: https://godbolt.org/z/1Ej5jxYPa

$ cat a.c
int printf(const char *, ...);
short a, b;
unsigned char c = 255;
int main() {
  int d;
  unsigned char e;
  d = 0;
  for (; a >= 0; a--) {
    int *f = &d;
    *f = c;
  }
  e = 0;
  for (; (unsigned char)(d - 255) + e <= 1; e++)
    printf("%d\n", b);
}
$
$ gcc -O0 a.c && ./a.out
0
0
$ gcc -Os a.c && ./a.out
$

Reply via email to