This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/2207: dtor and operator delete have different object
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/2207: dtor and operator delete have different object
- From: teemu at torma dot org
- Date: 7 Mar 2001 17:15:55 -0000
- Reply-To: teemu at torma dot org
>Number: 2207
>Category: c++
>Synopsis: dtor and operator delete have different object
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Mar 07 09:16:05 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: teemu@torma.org
>Release: gcc version 3.0 20010307 (prerelease)
>Organization:
>Environment:
i686-pc-linux-gnu (RedHat 6.2)
>Description:
When deleting on object pointed by a global variable,
and the dtor of the object modifies that variable, the new
modified value is passed to operator delete, which will
delete wrong object.
>How-To-Repeat:
Compile the file as g++ -S, and see the code generated
to method Foo::delete_current(). When it calls operator delete,
it reloads the pointer from Foo::current, but it is wrong,
since Foo::~Foo () already changed it. In this example,
the bar destructor is called, but foo is passed to operator
delete.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug.cc"
c3RydWN0IEZvbwp7CiAgc3RhdGljIEZvbyAqY3VycmVudDsKICBGb28gKnBhcmVudDsKCiAgRm9v
ICgpCiAgICB7IHBhcmVudCA9IGN1cnJlbnQ7IGN1cnJlbnQgPSB0aGlzOyB9CiAgfkZvbyAoKQog
ICAgeyBjdXJyZW50ID0gcGFyZW50OyB9CgogIHN0YXRpYyB2b2lkIGRlbGV0ZV9jdXJyZW50ICgp
Owp9OwoKRm9vICpGb286OmN1cnJlbnQgPSAwOwoKbWFpbiAoKQp7CiAgRm9vICpmb28gPSBuZXcg
Rm9vOwogIEZvbyAqYmFyID0gbmV3IEZvbzsKICBGb286OmRlbGV0ZV9jdXJyZW50ICgpOwp9Cgp2
b2lkCkZvbzo6ZGVsZXRlX2N1cnJlbnQgKCkKewogIGlmIChjdXJyZW50LT5wYXJlbnQpCiAgICBk
ZWxldGUgY3VycmVudDsKfQo=