https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102606
Bug ID: 102606
Summary: miscompilation of a program with large array in a
dead-code
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: k.even-mendoza at imperial dot ac.uk
Target Milestone: ---
This program miscompiled with gcc-12 (and also older versions) with -O0:
#include "stdio.h"
void foo(int *p)
{
if(0) // Dead-code
{
int *i[(3500)][(300)];
}
}
int main()
{
int i = 1;
foo(&i);
printf("1\n");
return 0;
}
the program terminates with Segmentation fault when compiled with -O0 and GCC,
but
with -O1,O2,O3,Os and clang (all flags), it prints "1" and return 0.
I assume the definition of "i" is being pulled up, out side the if(0) block.
I used gcc (GCC) 12.0.0 20210811 (experimental).