gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime5.C
raw| 1 | // { dg-do compile { target c++14 } } |
| 2 | // { dg-options "-Wno-return-local-addr" } |
| 3 | |
| 4 | constexpr const int& id(int x) { return x; } |
| 5 | |
| 6 | constexpr bool test() { |
| 7 | const int& y = id(3); |
| 8 | return y == 3; // { dg-error "outside its lifetime" } |
| 9 | } |
| 10 | |
| 11 | constexpr bool x = test(); // { dg-message "in .constexpr. expansion" } |