| 1 |
// PR rtl-optimization/48549 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-fcompare-debug -O2" } |
| 4 |
|
| 5 |
__extension__ typedef __PTRDIFF_TYPE__ pdiff_t; |
| 6 |
|
| 7 |
void |
| 8 |
foo (void *from, void *to) |
| 9 |
{ |
| 10 |
pdiff_t offset = reinterpret_cast <pdiff_t>(to) |
| 11 |
- reinterpret_cast <pdiff_t>(from); |
| 12 |
if (offset != static_cast <int>(offset)) |
| 13 |
*(int *) 0xC0DE = 0; |
| 14 |
reinterpret_cast <int *>(from)[1] = offset; |
| 15 |
} |
| 16 |
struct A |
| 17 |
{ |
| 18 |
A () : a () {} |
| 19 |
A (void *x) : a (x) {} |
| 20 |
void *bar () { return a; } |
| 21 |
void *a; |
| 22 |
}; |
| 23 |
struct C; |
| 24 |
struct D; |
| 25 |
struct E : public A |
| 26 |
{ |
| 27 |
C m1 (int); |
| 28 |
D m2 (); |
| 29 |
E () {} |
| 30 |
E (A x) : A (x) {} |
| 31 |
}; |
| 32 |
struct C : public E |
| 33 |
{ |
| 34 |
C () {} |
| 35 |
C (void *x) : E (x) {} |
| 36 |
}; |
| 37 |
struct D : public E |
| 38 |
{ |
| 39 |
D (void *x) : E (x) {} |
| 40 |
}; |
| 41 |
C |
| 42 |
E::m1 (int x) |
| 43 |
{ |
| 44 |
return (reinterpret_cast <char *>(bar ()) + x); |
| 45 |
} |
| 46 |
D |
| 47 |
E::m2 () |
| 48 |
{ |
| 49 |
return reinterpret_cast <char *>(bar ()); |
| 50 |
} |
| 51 |
struct B |
| 52 |
{ |
| 53 |
E a; |
| 54 |
unsigned b : 16; |
| 55 |
unsigned c : 1; |
| 56 |
}; |
| 57 |
void |
| 58 |
baz (B *x) |
| 59 |
{ |
| 60 |
for (unsigned i = 0; i < 64; i++) |
| 61 |
{ |
| 62 |
D d = x[i].a.m2 (); |
| 63 |
C c = x[i].a.m1 (x[i].c); |
| 64 |
foo (d.bar (), c.bar ()); |
| 65 |
} |
| 66 |
} |