projects
/
gcc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
917a9fd
)
re PR c++/13865 ([tree-ssa] dtor runs prematurely for loop-scoped variable)
author
Jason Merrill
<jason@gcc.gnu.org>
Fri, 30 Jan 2004 04:35:26 +0000
(23:35 -0500)
committer
Jason Merrill
<jason@gcc.gnu.org>
Fri, 30 Jan 2004 04:35:26 +0000
(23:35 -0500)
PR c++/13865
* c-simplify.c (gimplify_for_stmt): Reorganize to fix cleanups.
[[Split portion of a mixed commit.]]
From-SVN: r76923.2
gcc/testsuite/g++.dg/init/for1.C
[new file with mode: 0644]
patch
|
blob
diff --git a/gcc/testsuite/g++.dg/init/for1.C
b/gcc/testsuite/g++.dg/init/for1.C
new file mode 100644
(file)
index 0000000..
02f8a2d
--- /dev/null
+++ b/
gcc/testsuite/g++.dg/init/for1.C
@@ -0,0
+1,28
@@
+// PR c++/13865
+// Bug: We were destroying 'a' before executing the loop.
+
+#include <stdio.h>
+
+int i;
+int r;
+
+class A
+{
+public:
+ A() { printf("A ctor\n"); }
+ ~A()
+ {
+ printf("A dtor\n");
+ if (i != 1)
+ r = 1;
+ }
+};
+
+int main(int argc, char **argv)
+{
+ for (A a; i < 2; ++i) {
+ printf("iteration %d\n", i);
+ }
+
+ return r;
+}