This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17996] New: [3.4/4.0 regression] Destructor run twice
- From: "reichelt at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Oct 2004 11:01:25 -0000
- Subject: [Bug c++/17996] New: [3.4/4.0 regression] Destructor run twice
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following testcase is miscompiled on the 3.4 branch and mainline:
=========================================================
extern int printf(const char *restrict, ...) throw ();
struct A
{
A() { printf("Ctor\n"); }
~A() { printf("Dtor\n"); }
};
A a;
extern A a;
int main()
{
return 0;
}
=========================================================
The output is:
Ctor
Dtor
Dtor
i.e. the destructor of A is run twice.
If I exchange line 9 and 10, the bug goes away.
Btw, the bug was reported at Debian:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=260747
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=265961
The bug affects gcc 3.4.0 and later.
It was introduced somewhere in Mid August 2003.
Mark, your patch
http://gcc.gnu.org/ml/gcc-cvs/2003-08/msg00621.html
might have caused the regression. Could you please have a look?
--
Summary: [3.4/4.0 regression] Destructor run twice
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: reichelt at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org,mark at codesourcery dot
com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17996