| 1 |
// PR tree-optimization/37716 |
| 2 |
// { dg-do compile } |
| 3 |
|
| 4 |
struct A |
| 5 |
{ |
| 6 |
struct B |
| 7 |
{ |
| 8 |
int a, b, c, d; |
| 9 |
void *e[1]; |
| 10 |
}; |
| 11 |
B *d; |
| 12 |
inline void **f1 (int i) const |
| 13 |
{ |
| 14 |
return d->e + d->c + i; |
| 15 |
} |
| 16 |
}; |
| 17 |
|
| 18 |
template <typename T> |
| 19 |
struct C |
| 20 |
{ |
| 21 |
struct D |
| 22 |
{ |
| 23 |
void *v; |
| 24 |
inline T & f3 () |
| 25 |
{ |
| 26 |
return *reinterpret_cast <T *> (this); |
| 27 |
} |
| 28 |
}; |
| 29 |
union |
| 30 |
{ |
| 31 |
A p; |
| 32 |
A::B *d; |
| 33 |
}; |
| 34 |
T & operator[](int i) |
| 35 |
{ |
| 36 |
if (d->a != 1) |
| 37 |
f2 (); |
| 38 |
return reinterpret_cast <D *> (p.f1 (i))->f3 (); |
| 39 |
} |
| 40 |
void f2 (); |
| 41 |
void f3 (int i, const T & t); |
| 42 |
}; |
| 43 |
|
| 44 |
class E |
| 45 |
{ |
| 46 |
int e, f; |
| 47 |
}; |
| 48 |
|
| 49 |
C <E> c; |
| 50 |
|
| 51 |
void |
| 52 |
foo (int x) |
| 53 |
{ |
| 54 |
E e = c[x]; |
| 55 |
c.f3 (x, e); |
| 56 |
} |