https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88854
Bug ID: 88854 Summary: redundant store after load that would makes aliasing UB Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: kretz at kde dot org CC: rguenth at gcc dot gnu.org Target Milestone: --- Test cases: This is optimized at -O1 and with GCC 5 at -O2. -fdisable-tree-fre1 and -fno-strict-aliasing also remove the store to a. void f(int *a, float *b) { int x = *a; *b = 0; x = *a; *a = x; } The following is an extension that reloads *a after store to b into a different variable. Still the store to a must be dead, since otherwise the read of a would be UB. int g(int *a, float *b) { int x = *a; *b = 0; int r = *a; *a = x; return r; }