Dead
[official-gcc.git] / gomp-20050608-branch / gcc / testsuite / g++.dg / tree-ssa / 20040317-1.C
blobe2f3dcdceb8752fdf205f52a8b45b3704fdd326a
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
4 /* Test provided by Brian Ryner in PR 14511.  The alias analyzer was
5    not handling structures containing arrays properly.  In this case,
6    the static cast was introducing two assignments of the form
8           this_6->_vptr.IFoo = &_ZTV4IFoo[2];
9           this_4->_vptr.IFoo = &_ZTV3Bar[2];
11    which were not considered to alias each other because the alias
12    analyzer was not computing a proper pointer to array elements.
13    Another related bug was the type based alias analyzer not computing
14    alias relations to _ZTV4IFoo and _ZTV3Bar.  Since those variables
15    are read-only, it was disregarding alias information for them.
16    So, the memory tags for the two 'this' variables were not being
17    marked as aliased with these variables.  Resulting in the two
18    assignments not aliasing each other.
20    This was causing the optimizers to generate a call to the virtual
21    method Foo() instead of the overloaded version.  */
23 struct IFoo
25   virtual void Foo() = 0;
28 struct Bar : IFoo
30   void Foo() { }
33 int main(int argc, char **argv)
35   Bar* b = new Bar();
36   static_cast<IFoo*>(b)->Foo();
37   return 0;