diff options
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.jason/temporary3.C')
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.jason/temporary3.C | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/temporary3.C b/gcc/testsuite/g++.old-deja/g++.jason/temporary3.C new file mode 100644 index 00000000000..ec5984c3aee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/temporary3.C @@ -0,0 +1,26 @@ +// Bug: the temporary returned from f is elided, causing a to be constructed +// twice but only destroyed once. + +extern "C" int printf (const char *, ...); + +int c,d; + +struct A { + A (int) { c++; } + ~A () { d++; } + A (const A&) { c++; } + int i; +}; + +A f () +{ return 1; } + +main () +{ + { + A a (1); + a = f (); + } + printf ("%d %d\n", c, d); + return c != d; +} |