https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98255
Bug ID: 98255 Summary: wrong code at -Os and above with -fPIC on x86_64-pc-linux-gnu Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: zhendong.su at inf dot ethz.ch Target Milestone: --- [510] % gcctk -v Using built-in specs. COLLECT_GCC=gcctk COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk/configure --disable-bootstrap --prefix=/local/suz-local/software/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib --with-system-zlib Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.0 20201212 (experimental) [master revision ff2dfdef2f2:87144b47033:815eb852a2d293331eba2e241a986b8641d4da1f] (GCC) [511] % [511] % gcctk -Os small.c; ./a.out [512] % [512] % gcctk -Os -fPIC small.c [513] % ./a.out Segmentation fault [514] % [514] % cat small.c struct a { volatile unsigned b; unsigned c; }; int d, *e, h, k, l; static struct a f; long g; static unsigned i = 4294967294; volatile int j; long m() { char n[4][4][3] = {{{9, 2, 8}, {9, 2, 8}, {9, 2, 8}, {9}}, {{8}}, {{8}}, {{2}}}; while (d) { for (; f.c < 4; f.c++) { *e = 0; h = n[f.c + 4][0][d]; } while (g) return n[0][3][i]; while (1) { if (k) { j = 0; if (j) continue; } if (l) break; } } return 0; } int main() { m(); return 0; }