Created attachment 24048 [details] The entire program The following program crashes if compiled with -O2: for (int i=0; i<=1; i++) for (int j=0; j<=1; j++) { std::vector<int> a[2]; a[i].push_back (0); } If we remove any 'for' loop, or if we change a[i] to a[0] or to a[1] - there will be no crash.
I can reproduce this on the trunk.
-fno-strict-aliasing makes it work.
Created attachment 24049 [details] partially reduced testcase $ g++ testcase.C -O2 $ valgrind -q ./a.out ==20686== Invalid write of size 4 ==20686== at 0x400625: main (testcase.C:54) ==20686== Address 0x4 is not stack'd, malloc'd or (recently) free'd
The aliasing problem does not show up until sched2.
D.2398_16->D.2250._M_impl._M_finish MEM[(struct _Vector_impl *)&a + 24B]._M_finish Should conflict but don't
Created attachment 24050 [details] reduced testcase I am not sure if it is reduced correctly. However, -fno-strict-aliasing prevents the crash.
Mine.
Author: rguenth Date: Wed Apr 20 13:11:06 2011 New Revision: 172768 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172768 Log: 2011-04-20 Richard Guenther <rguenther@suse.de> PR middle-end/48695 * tree-ssa-alias.c (aliasing_component_refs_p): Compute base objects and types here. Adjust for their offset before comparing. * g++.dg/torture/pr48695.C: New testcase. Added: trunk/gcc/testsuite/g++.dg/torture/pr48695.C Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-alias.c
Fixed on trunk sofar.
Fixed.
Author: rguenth Date: Thu Apr 21 14:40:53 2011 New Revision: 172831 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172831 Log: 2011-04-21 Richard Guenther <rguenther@suse.de> PR middle-end/48695 * tree-ssa-alias.c (aliasing_component_refs_p): Compute base objects and types here. Adjust for their offset before comparing. * g++.dg/torture/pr48695.C: New testcase. Added: branches/gcc-4_6-branch/gcc/testsuite/g++.dg/torture/pr48695.C Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/testsuite/ChangeLog branches/gcc-4_6-branch/gcc/tree-ssa-alias.c