Bug 21233 - 2.91.66, 2.95.2 and 2.96 seem to call too many destructors.
Summary: 2.91.66, 2.95.2 and 2.96 seem to call too many destructors.
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.0
Hardware: i386
OS: Linux
high
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-11-22 10:05 UTC by Need Real Name
Modified: 2005-10-31 22:00 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-10-01 21:01:34 UTC
Embargoed:


Attachments (Terms of Use)
cpp file to replicate problem. (1.03 KB, text/plain)
2000-11-22 10:09 UTC, Need Real Name
no flags Details

Description Need Real Name 2000-11-22 10:05:24 UTC
There appears to be a bug in gcc. This is also reported on the gcc buglist
(bug number 670), this report (GNATS) has an attached cpp file that
demonstrates the problem which seems to cause the compiler to call one (or
more) too many destructors, we detected the problem whilst porting an HP
application to Linux and traced the core dumps etc. to some code that
wasn't too well written (i.e. it was passing the object by value instead of
by reference) anyway it appears the compiler does something horrible, calls
too many destructors, and when we try to delete the object/use the
object.... BANG.

I feel this is a major issue as the affected programs terminate immediatly,
seriously reducing the credibility of C++ on Linux.

Comment 1 Need Real Name 2000-11-22 10:09:47 UTC
Created attachment 5643 [details]
cpp file to replicate problem.

Comment 2 Ralph Loader 2000-11-27 03:44:53 UTC
Seeing something similar.  For me, constructors not being called when they
should (which could result in the symptoms above - more destructors than
constructors being called).

I'm willing to try and produce a test case for the exact situation I'm seeing,
but the code is fairly convoluted, so I'll only do so if someone asks.

Comment 3 Adrian Miranda 2001-02-15 03:09:01 UTC
The original problem does indeed appear to be a bug in g++, where it decides to
create a temporary variable, and just copies it without bothering to call the
contructor.  You can see this better by adding a little bit to the debugging
messages in the constructors and destructors, in the sample code provided by
sclarke.  Just tell them to print the value of this.  As you will see, the first
destructor called is on a variable for which no constructor was called.  You can
work around the problem by modifying the Holder Constructor to take a "const
Counter&", then the temp variable isn't created, and everything is fine.

The bug (if it is one) seems to be in gcc 2.95.2, but does not appear to be in
the latest snapshot of gcc.  Assuming it has been fixed, perhaps the fix can be
backported to gcc 2.96 for redhat 7.1?

I hope my message is reasonably clear.  Please let me know if I can give further
information.


Comment 4 Richard Henderson 2004-10-01 21:01:34 UTC
http://gcc.gnu.org/PR670 shows this bug fixed in gcc 3.0.


Note You need to log in before you can comment on or make changes to this bug.