c++: -Wdangling-reference with reference wrapper [PR107532]
[official-gcc.git] / gcc / testsuite / g++.dg / warn / Wdangling-reference9.C
blob9ad83f7365ee4ef231c3275b3463c6ca79887392
1 // PR c++/107532
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wdangling-reference" }
5 #include <functional>
7 struct X { int n; };
9 struct S {
10   std::reference_wrapper<const X> wrapit() const { return x; }
11   X x;
14 void
15 g (const S& s)
17   const auto& a1 = s.wrapit().get();
18   (void) a1;
19   const auto& a2 = S().wrapit().get(); // { dg-warning "dangling reference" }
20   (void) a2;