gcc/testsuite/g++.dg/cpp1y/constexpr-nsdmi4.C
raw| 1 | // PR c++/94219 |
| 2 | // { dg-do compile { target c++14 } } |
| 3 | |
| 4 | struct A { long x; }; |
| 5 | |
| 6 | struct U; |
| 7 | constexpr A foo(U *up); |
| 8 | |
| 9 | struct U { |
| 10 | A a = foo(this); int y; |
| 11 | }; |
| 12 | |
| 13 | constexpr A foo(U *up) { |
| 14 | up->y = 11; |
| 15 | return {42}; |
| 16 | } |
| 17 | |
| 18 | extern constexpr U u = {}; |
| 19 | |
| 20 | static_assert(u.y == 11, ""); |
| 21 | static_assert(u.a.x == 42, ""); |