| 1 |
/* PR c/32041 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
|
| 4 |
struct S |
| 5 |
{ |
| 6 |
int c; |
| 7 |
struct { float f; } sa[2]; |
| 8 |
}; |
| 9 |
|
| 10 |
char a[__builtin_offsetof (S, sa->f) |
| 11 |
== __builtin_offsetof (S, sa[0].f) ? 1 : -1]; |
| 12 |
|
| 13 |
template <int N> |
| 14 |
struct T |
| 15 |
{ |
| 16 |
int c[N]; |
| 17 |
struct { float f; } sa[N]; |
| 18 |
static int foo () { return __builtin_offsetof (T, sa->f); } |
| 19 |
static int bar () { return __builtin_offsetof (T, sa[0].f); } |
| 20 |
}; |
| 21 |
|
| 22 |
char b[__builtin_offsetof (T<5>, sa->f) |
| 23 |
== __builtin_offsetof (T<5>, sa[0].f) ? 1 : -1]; |
| 24 |
|
| 25 |
int |
| 26 |
main () |
| 27 |
{ |
| 28 |
if (T<1>::foo () != T<1>::bar ()) |
| 29 |
__builtin_abort (); |
| 30 |
if (T<7>::foo () != T<7>::bar ()) |
| 31 |
__builtin_abort (); |
| 32 |
} |