gcc/testsuite/g++.dg/cpp1y/constexpr-89285-2.C
raw| 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 { |
| 17 | B bar {this}; |
| 18 | }; |
| 19 | |
| 20 | C foo {}; |