// PR c++/113256 // { dg-do compile { target c++14 } } // { dg-options "-Wdangling-reference" } // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } } #include #include template auto bind(M T::* pm, A) { return [=]( auto&& x ) -> M const& { return x.*pm; }; } template struct arg {}; arg<1> _1; int main() { std::pair pair; int const& x = bind( &std::pair::first, _1 )( pair ); // { dg-bogus "dangling reference" } assert( &x == &pair.first ); }