https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111469
Bug ID: 111469
Summary: Wrong code at -Os on x86_64-linux-gnu since
r14-573-g69f1a8af45
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: pinskia at gcc dot gnu.org
Target Milestone: ---
gcc at -Os produced the wrong code.
Bisected to r14-573-g69f1a8af45
Compiler explorer: https://godbolt.org/z/fheon13dP
$ cat a.c
int printf(const char *, ...);
int a;
long b, c, e, f;
char *g;
unsigned short h = 5;
static unsigned short *i = &h;
unsigned j;
long k(long m, long n) {
if (n)
e = m;
c = e;
return e;
}
char o() {
char l;
while (f)
;
l = *g;
return l;
}
int main() {
int p;
int q;
for (; j - 9 >= 29; j = k(-95, *i) + 127) {
*i || o();
long d = h;
p = d == 0 ? 0 : b % d;
q = p;
int *r[1] = {&q};
}
printf("%d\n", a);
}
$
$ gcc a.c && ./a.out
0
$ gcc a.c -Os && ./a.out
segmentation fault
$