1// { dg-do assemble } 2class X // Indentation has been done so to see the similarities. 3{ 4public: 5 X() {} // { dg-error "" } referenced below 6 X(X& x) {x.i=7;} // { dg-error "" } Both functions modify the 7 void bar(X& x) {x.i=7;} // { dg-error "" } reference parameter x. 8 int i; 9}; 10 11X foo() { X x; return x; } 12 13int main() 14{ 15 X x(foo()); // { dg-error "" } Compiler doesn't warn about temporary reference. 16 x.bar(foo()); // { dg-error "" } The same mistake is warned about in this case. 17} 18