diff options
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.jason/temporary4.C')
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.jason/temporary4.C | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/temporary4.C b/gcc/testsuite/g++.old-deja/g++.jason/temporary4.C new file mode 100644 index 00000000000..97ce95a81c0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/temporary4.C @@ -0,0 +1,31 @@ +// Bug: g++ initializes both B::i and B::j before destroying any temps. + +extern "C" int printf (const char *, ...); + +int c = 0; +int d = 0; +int r = 0; + +struct A { + A() { if (c != d) r = 1; ++c; } + A(const A&); // declare so g++ returns A on the stack + ~A() { ++d; } + operator int () { return 0; } +}; + +A foo () +{ + return A(); +} + +struct B { + int i; + int j; + B(): i(foo()), j(foo()) { } +}; + +main() +{ + B b; + return r; +} |