| 1 |
// PR c++/89285 |
| 2 |
// { dg-do compile { target c++14 } } |
| 3 |
|
| 4 |
struct A { |
| 5 |
int a {}; |
| 6 |
}; |
| 7 |
struct B { |
| 8 |
int b {}; |
| 9 |
constexpr B (A *x) { |
| 10 |
int *c = &x->a; |
| 11 |
while (*c) |
| 12 |
c = reinterpret_cast<int *>((reinterpret_cast<char *>(c) + *c)); |
| 13 |
*c = reinterpret_cast<char *>(this) - reinterpret_cast<char *>(c); // { dg-error "reinterpret_cast" "" { target c++20_down } } |
| 14 |
} |
| 15 |
}; |
| 16 |
struct C : A { // { dg-error "" "" { target c++14_down } } |
| 17 |
B bar {this}; |
| 18 |
}; |
| 19 |
|
| 20 |
// error path changes in C++17 due to `C` becoming an aggregate |
| 21 |
constexpr C foo {}; // { dg-error "" "" { target c++17 } } |