gcc/testsuite/g++.dg/cpp1y/constexpr-union5.C
raw| 1 | // { dg-do compile { target c++14 } } |
| 2 | |
| 3 | union U; |
| 4 | constexpr int foo(U *up); |
| 5 | |
| 6 | union U { |
| 7 | int a = foo(this); int y; |
| 8 | }; |
| 9 | |
| 10 | constexpr int foo(U *up) { |
| 11 | up->a++; // { dg-error "accessing uninitialized member" } |
| 12 | return {42}; |
| 13 | } |
| 14 | |
| 15 | extern constexpr U u = {}; // { dg-message "in .constexpr. expansion" } |