gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const6.C
raw| 1 | // PR c++/91264 |
| 2 | // { dg-do compile { target c++14 } } |
| 3 | |
| 4 | struct X { |
| 5 | mutable int j; |
| 6 | constexpr X() : j(0) { } |
| 7 | }; |
| 8 | |
| 9 | struct Y { |
| 10 | X x; |
| 11 | constexpr Y() : x{} { } |
| 12 | }; |
| 13 | |
| 14 | constexpr void |
| 15 | g () |
| 16 | { |
| 17 | const Y y; |
| 18 | Y *p = const_cast<Y *>(&y); |
| 19 | p->x.j = 99; |
| 20 | } |
| 21 | |
| 22 | static_assert((g(), 1), ""); |