PR c++/56973, DR 696 - capture constant variables only as needed.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / pr77591.C
blob8f9e28c850113cbdeb9a4535c439e2f67f782739
1 // PR c++/77591
2 // { dg-do compile { target c++14 } }
3 // { dg-options "-O0 -Wreturn-local-addr" }
5 class A { };
7 decltype(auto)
8 foo ()
10   A c;                  // { dg-warning "reference to local variable 'c' returned" }
11   return (c);
14 decltype(auto)
15 bar ()
17   A c;                  // { dg-warning "reference to local variable 'c' returned" }
18   return 1==1 ? c : c;