| 1 |
// PR c++/96241 |
| 2 |
// { dg-do compile { target c++14 } } |
| 3 |
|
| 4 |
#define assert(expr) static_assert (expr, #expr) |
| 5 |
|
| 6 |
enum E { o }; |
| 7 |
|
| 8 |
struct S { |
| 9 |
int e = o; |
| 10 |
}; |
| 11 |
|
| 12 |
using T = S[3]; |
| 13 |
|
| 14 |
constexpr struct S s[1][1][1] = { }; |
| 15 |
assert (0 == s[0][0][0].e); |
| 16 |
|
| 17 |
constexpr int |
| 18 |
fn0 () |
| 19 |
{ |
| 20 |
return T{}[0].e; |
| 21 |
} |
| 22 |
assert(fn0 () == 0); |
| 23 |
|
| 24 |
constexpr int |
| 25 |
fn1 () |
| 26 |
{ |
| 27 |
S d[1]; |
| 28 |
int x = d[0].e; |
| 29 |
return x; |
| 30 |
} |
| 31 |
assert(fn1 () == 0); |
| 32 |
|
| 33 |
constexpr int |
| 34 |
fn2 () |
| 35 |
{ |
| 36 |
S d[1]; |
| 37 |
return d[0].e; |
| 38 |
} |
| 39 |
assert(fn2 () == 0); |
| 40 |
|
| 41 |
constexpr int |
| 42 |
fn3 () |
| 43 |
{ |
| 44 |
struct X { int e = o; } d[1]{}; |
| 45 |
return d[0].e; |
| 46 |
} |
| 47 |
assert(fn3 () == 0); |