| 1 |
// PR c++/118239 |
| 2 |
// { dg-do "compile" { target c++11 } } |
| 3 |
|
| 4 |
struct NoMut1 { |
| 5 |
int a, b; |
| 6 |
}; |
| 7 |
|
| 8 |
// Reported case. |
| 9 |
struct NoMut2 : NoMut1 { |
| 10 |
constexpr NoMut2(int a, int b) /*: NoMut1()*/ |
| 11 |
{} // { dg-error "must be initialized" "" { target c++17_down } } |
| 12 |
}; |
| 13 |
|
| 14 |
// Variant with explicit initialization of some member. |
| 15 |
struct NoMut3 : NoMut1 { |
| 16 |
constexpr NoMut3(int a, int b) : c(0) /*, NoMut1()*/ |
| 17 |
{} // { dg-error "must be initialized" "" { target c++17_down } } |
| 18 |
int c; |
| 19 |
}; |
| 20 |
|
| 21 |
void mutable_subobjects() { |
| 22 |
constexpr NoMut2 nm2(1, 2); // { dg-error "constant expression" } |
| 23 |
constexpr NoMut3 nm3(1, 2); // { dg-error "constant expression" } |
| 24 |
} |