This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++ 2.95.2: goto+dtor bug
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Re: c++ 2.95.2: goto+dtor bug
- From: grahams <grahams at rcp dot co dot uk>
- Date: Sat, 12 Feb 2000 19:26:24 +0000
- References: <20000212192835.A15999@long.yar.ru>
Hi
This bug also exists in the current CVS as of 12th Feb.
Here are a couple of modified versions of
the original test case which show that its
only some destructors which don't get called.
Graham
---------------------------------------------------
#include <stdio.h>
class a
{
private:
int n;
public:
a(int x) { n = x; printf("ctor %d\n", n); }
~a() { printf("dtor %d\n", n); }
};
int main(int argc,char **argv)
{
a var0(0);
if(argc>1)
{
leave:
return 0;
}
a var1(1);
a var2(2);
goto leave;
}
---------------------------------------------------
Here's the output
ctor 0
ctor 1
ctor 2
dtor 2
dtor 0
---------------------------------------------------
#include <stdio.h>
class a
{
private:
int n;
public:
a(int x) { n = x; printf("ctor %d\n", n); }
~a() { printf("dtor %d\n", n); }
};
int main(int argc,char **)
{
a var0(0);
if(argc>1)
{
leave:
return 0;
}
a var1(1);
a var2(2);
if (argc>1)
{
leave2:
goto leave;
}
a var3(3);
a var4(4);
goto leave2;
}
---------------------------------------------------
Here's the output
ctor 0
ctor 1
ctor 2
ctor 3
ctor 4
dtor 4
dtor 2
dtor 0