Bug 26100 - Destructor called twice
Summary: Destructor called twice
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.4
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-05 06:20 UTC by Ivan Godard
Modified: 2006-02-05 12:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
source code (287 bytes, application/octet-stream)
2006-02-05 06:21 UTC, Ivan Godard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Godard 2006-02-05 06:20:49 UTC
The attached code does various things with a type ("inv") that increments a count on constructor calls and decrements on destructor calls. As there are no declarations of this type, only temporaries, the net should be zero at the end of each statement. Unfortunately, the count goes negative.

Ivan
Comment 1 Ivan Godard 2006-02-05 06:21:17 UTC
Created attachment 10780 [details]
source code
Comment 2 Richard Biener 2006-02-05 12:26:36 UTC
You are missing copy constructor invocations.  Add

                inv(const inv&) { ++count; }