Bug 17996 - [3.4/4.0 regression] Destructor run twice
Summary: [3.4/4.0 regression] Destructor run twice
Status: RESOLVED DUPLICATE of bug 17976
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.3
: P2 critical
Target Milestone: 3.4.3
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2004-10-14 11:01 UTC by Volker Reichelt
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.5
Known to fail: 3.4.0 3.4.3 4.0.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2004-10-14 11:01:13 UTC
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?
Comment 1 Volker Reichelt 2004-10-14 11:25:24 UTC
Mark, I just checked, the regression indeed appears with your patch
http://gcc.gnu.org/ml/gcc-cvs/2003-08/msg00621.html
Comment 2 Andrew Pinski 2004-10-14 12:28:08 UTC

*** This bug has been marked as a duplicate of 17976 ***