Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/constexpr-lifetime1.C

raw
1 // PR c++/96630
2 // { dg-do compile { target c++14 } }
3
4 struct S {
5 int x = 0;
6 constexpr const int& get() const { return x; }
7 };
8
9 constexpr const int& test() {
10 auto local = S{}; // { dg-message "note: declared here" }
11 return local.get();
12 }
13 constexpr int x = test(); // { dg-error "accessing .local. outside its lifetime" }