Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.old-deja/g++.jason/temporary2.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
// { 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; } 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. }