Daily bump.
[gcc.git] / gcc / testsuite / g++.dg / warn / Wdangling-reference14.C
blobb83266ee6a808a0a79545b4c60fde46739c465e2
1 // PR c++/113256
2 // { dg-do compile { target c++14 } }
3 // { dg-options "-Wdangling-reference" }
4 // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } }
6 #include <utility>
7 #include <cassert>
9 template<class M, class T, class A> auto bind(M T::* pm, A)
11     return [=]( auto&& x ) -> M const& { return x.*pm; };
14 template<int I> struct arg {};
16 arg<1> _1;
18 int main()
20     std::pair<int, int> pair;
21     int const& x = bind( &std::pair<int, int>::first, _1 )( pair ); // { dg-bogus "dangling reference" }
22     assert( &x == &pair.first );