This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13865] [tree-ssa] dtor runs prematurely for loop-scoped variable
- From: "bryner at brianryner dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Jan 2004 23:49:13 -0000
- Subject: [Bug c++/13865] [tree-ssa] dtor runs prematurely for loop-scoped variable
- References: <20040126062654.13865.bryner@brianryner.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bryner at brianryner dot com 2004-01-26 23:49 -------
This testcase is even simpler:
#include <stdio.h>
class A
{
public:
A() { printf("A ctor\n"); }
~A() { printf("A dtor\n"); }
};
int main(int argc, char **argv)
{
int i = 0;
for (A a; i < 2; ++i) {
printf("iteration %d\n", i);
}
return 0;
}
which outputs:
A ctor
A dtor
iteration 0
iteration 1
instead of:
A ctor
iteration 0
iteration 1
A dtor
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13865