https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103860
Bug ID: 103860 Summary: wrong code at -O3 with -fPIC on x86_64-linux-gnu Product: gcc Version: unknown 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: --- It appears to be a regression from GCC 5.4, and impact GCC 6.1 and later. [591] % 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/12.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 --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20211228 (experimental) (GCC) [592] % [592] % gcctk -O3 small.c; ./a.out [593] % gcctk -O2 -fPIC small.c; ./a.out [594] % [594] % gcctk -O3 -fPIC small.c [595] % ./a.out Segmentation fault [596] % [596] % cat small.c char a(char b, char c) { return b + c; } static int d, *e; int f; int main() { char l = -1; for (; l; l = a(l, 1)) { while (d < 0) ; if (d > 0) { f = 0; *e = 0; } } d = 0; return 0; }