Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/decltype-auto6.C

raw
1 // PR c++/101165 - P2266R1 - Simpler implicit move
2 // { dg-do compile { target c++14 } }
3 // A variant of cxx23/elision1.C:eight, just with ().
4
5 struct Widget {
6 Widget(Widget&&);
7 };
8
9 Widget val();
10
11 decltype(auto)
12 foo ()
13 {
14 decltype(auto) x = val(); // OK, x is Widget
15 // We deduce the return type to int&&, therefore we're doing something
16 // we ought not to be doing -- returning a reference to a local variable!
17 // In C++20, we deduce to int&, but that has the same problem!
18 return (x); // { dg-warning "reference to local variable" }
19 }