aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.law/dtors2.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.law/dtors2.C')
-rw-r--r--gcc/testsuite/g++.old-deja/g++.law/dtors2.C40
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.law/dtors2.C b/gcc/testsuite/g++.old-deja/g++.law/dtors2.C
new file mode 100644
index 00000000000..c1f2d423cc4
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.law/dtors2.C
@@ -0,0 +1,40 @@
+// GROUPS passed destructors
+#include <stdio.h>
+
+int destruct = 0;
+
+class bla {
+
+public:
+
+ inline bla(char * jim) { ; };
+
+ inline ~bla() { destruct++; if (destruct == 2) printf ("PASS\n");};
+};
+
+class ulk {
+
+public:
+
+ inline ulk() {};
+ inline ~ulk() {};
+
+ void funk(const bla & bob) { ;};
+ // ^ interestingly, the code compiles right if
+ // this & is deleted (and therefore the parameter
+ // passed as value)
+};
+
+main() {
+
+ ulk dumm;
+
+ dumm.funk(bla("laberababa")); // this compiles correctly
+
+ dumm.funk((bla)"laberababa"); // this produces incorrect code -
+ // the temporary instance of
+ // the class "bla" is constructed
+ // but never destructed...
+
+
+}