1 // { dg-options "-O2" } 2 3 // Contributed by Nathan Sidwell 22 Dec 2003 <nathan@codesourcery.com> 4 // Origin: rsandifo@redhat.com 5 6 // PR c++/13387. Alias sets were incorrect 7 8 struct C { ptrC9 C(short *p = 0, int i = 0) : ptr (p), index (i) {} 10 short operator*() { return ptr[index]; } 11 short *ptr; 12 int index; 13 }; 14 15 C f1 (C) __attribute__ ((noinline)); f1(C x)16C f1 (C x) 17 { 18 return x; 19 } 20 21 void f2 (short)__attribute__ ((noinline));; 22 short s; 23 f2(short s_)24void f2 (short s_) 25 { 26 s = s_; 27 } 28 29 C g (C x)__attribute__ ((noinline)); g(C x)30C g (C x) 31 { 32 x = f1 (x); 33 f2 (*x); 34 return x; 35 } 36 main()37int main () 38 { 39 short p[2] = { 0x1234, 0x5678 }; 40 C x (p, 1); 41 42 g (x); 43 44 return s != p[1]; 45 } 46