blob: 2709b50e7f1f07ce1d257de8f5efae3333147ca4 [file] [log] [blame]
// { dg-do assemble }
class X // Indentation has been done so to see the similarities.
{
public:
X() {}
X(X& x) {x.i=7;} // { dg-message "note" "" { target c++14_down } } Both functions modify the
void bar(X& x) {x.i=7;} // { dg-message "note" } reference parameter x.
int i;
};
X foo() { X x; return x; } // { dg-error "cannot bind non-const lvalue reference" "" { target c++23 } }
int main()
{
X x(foo()); // { dg-error "rvalue" "" { target c++14_down } } Compiler doesn't warn about temporary reference.
x.bar(foo()); // { dg-error "rvalue" } The same mistake is warned about in this case.
}