http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47621
Summary: Missed dependencies in address-taken optimization Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: uweig...@gcc.gnu.org CC: rguent...@suse.de The following program is mis-optimized with 4.6 (not earlier versions) at -O or higher optimization levels: int main (void) { int data = 1; struct ptr { int val; } *ptr = (struct ptr *) &data; ptr->val = 0; return data; } This program should return 0, but actually returns 1. After the "address-taken" optimization pass, we have: dataD.1975_4 = 1; MEM[(struct ptr *)&dataD.1975].valD.1977 = 0; D.3453_2 = dataD.1975_4; return D.3453_2; so the dependency between the assignment to ptr->val and the use of data is lost. See this post for more information: http://gcc.gnu.org/ml/gcc/2011-02/msg00079.html H.J. Lu identified the following patch as introducing the regression: http://gcc.gnu.org/ml/gcc-patches/2010-10/msg00788.html