| 1 |
// { dg-options "-O2" } |
| 2 |
|
| 3 |
// Contributed by Nathan Sidwell 22 Dec 2003 <[email protected]> |
| 4 |
// Origin: [email protected] |
| 5 |
|
| 6 |
// PR c++/13387. Alias sets were incorrect |
| 7 |
|
| 8 |
struct C { |
| 9 |
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)); |
| 16 |
C f1 (C x) |
| 17 |
{ |
| 18 |
return x; |
| 19 |
} |
| 20 |
|
| 21 |
void f2 (short)__attribute__ ((noinline));; |
| 22 |
short s; |
| 23 |
|
| 24 |
void f2 (short s_) |
| 25 |
{ |
| 26 |
s = s_; |
| 27 |
} |
| 28 |
|
| 29 |
C g (C x)__attribute__ ((noinline)); |
| 30 |
C g (C x) |
| 31 |
{ |
| 32 |
x = f1 (x); |
| 33 |
f2 (*x); |
| 34 |
return x; |
| 35 |
} |
| 36 |
|
| 37 |
int main () |
| 38 |
{ |
| 39 |
short p[2] = { 0x1234, 0x5678 }; |
| 40 |
C x (p, 1); |
| 41 |
|
| 42 |
g (x); |
| 43 |
|
| 44 |
return s != p[1]; |
| 45 |
} |