| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
|
| 3 |
struct S { void *p; }; |
| 4 |
struct T { S s; }; |
| 5 |
constexpr S s = { nullptr }; |
| 6 |
constexpr T t = { { nullptr } }; |
| 7 |
|
| 8 |
constexpr void * |
| 9 |
foo () |
| 10 |
{ |
| 11 |
return ((void **) &t)[0]; // { dg-error "reinterpret_cast" } |
| 12 |
} |
| 13 |
|
| 14 |
constexpr void * |
| 15 |
bar () |
| 16 |
{ |
| 17 |
return ((void **) &s)[0]; // { dg-error "reinterpret_cast" } |
| 18 |
} |
| 19 |
|
| 20 |
constexpr auto x = foo (); // { dg-error "called in a constant expression" } |
| 21 |
constexpr auto y = bar (); // { dg-error "called in a constant expression" } |