[Bug c++/13865] [tree-ssa] dtor runs prematurely for loop-scoped variable
bangerth at dealii dot org
gcc-bugzilla@gcc.gnu.org
Mon Jan 26 14:52:00 GMT 2004
------- Additional Comments From bangerth at dealii dot org 2004-01-26 14:52 -------
Confirmed indeed. And just to make sure that we don't have any copy
constructors running:
-------------------
#include <stdio.h>
struct A {
A(int val) : mValue(val) { printf("A ctor\n"); }
A(const A&a) : mValue(a.mValue) { printf("A copy ctor\n"); }
~A() { printf("A dtor\n"); }
int mValue;
};
int main()
{
int i = 0;
for (A a = A(i); a.mValue != 2; a = A(++i)) {
printf("iteration %d\n", i);
}
}
-------------------------
When run this never produces the "A copy ctor" output.
This may well be the cause of some memory corruption people have seen in
their codes when using tree-ssa.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |gerald at pfeifer dot com
Priority|P2 |P1
Last reconfirmed|2004-01-26 13:09:59 |2004-01-26 14:52:16
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13865
More information about the Gcc-bugs
mailing list