https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84003
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |alias, wrong-code Status|UNCONFIRMED |NEW Last reconfirmed| |2018-01-24 CC| |rguenth at gcc dot gnu.org Component|target |rtl-optimization Summary|FAIL: |FAIL: |g++.dg/torture/pr77745.C |g++.dg/torture/pr77745.C |with -fpic |with noinline foo Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. Goes wrong during sched2 which re-orders the read and writes in foo: foo (char * c1, char * c2) { long int _7; <bb 2> [local count: 1073741825]: MEM[(long int *)c1_1(D)] = 100; MEM[(long long int *)c2_4(D)] = 200; MEM[(long int *)c2_4(D)] = 200; _7 = MEM[(long int *)c1_1(D)]; return _7; compiles to _Z3fooPcS_: .LFB1: .cfi_startproc movl 4(%esp), %eax movl 8(%esp), %edx movl $100, (%eax) movl (%eax), %eax movl $200, (%edx) movl $0, 4(%edx) ret note c1_1 == c2_4. This must be a latent bug in scheduling somehow not triggered without -fpic (inlining probably). Indeed, marking foo as noinline makes it trigger without -fpic.