public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jamie@turbolabs.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/4871: value argument destructor called twice when a virtual method is called in virtual inherited class
Date: Fri, 02 Nov 2001 08:08:00 -0000	[thread overview]
Message-ID: <20011114021842.18845.qmail@sourceware.cygnus.com> (raw)


>Number:         4871
>Category:       c++
>Synopsis:       value argument destructor called twice when a virtual method is called in virtual inherited class
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 13 18:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jamie Painter <jamie@turboabs.com:>
>Release:        gcc version 3.0.2
>Organization:
>Environment:
Linux
>Description:
When a method is called with a class argument passed by value, under certain conditions the value is destructed twice.  The conditions seem to be related to the use of virtual inheritance, as demonstrated in the attached source.

>How-To-Repeat:
Compile (g++ gccbug.cpp), 
run (./a.out).

Observe the output:

constructing  ValueType 0xbffffa34
destructing   ValueType 0xbffffa34
destructing   ValueType 0xbffffa34

Note that the value parameter is constructed once and deconstructed twice.

Gcc 2.95.2 produces the correct output:

constructing  ValueType 0xbffff8a4
destructing   ValueType 0xbffff8a4

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="gccbug.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="gccbug.cpp"

I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IFZhbHVlVHlwZQp7CiAgVmFsdWVUeXBlKCkgIAog
IHsgCiAgICBzdGQ6OmNlcnIgPDwgImNvbnN0cnVjdGluZyAgVmFsdWVUeXBlICIgPDwgdGhpcyA8
PCBzdGQ6OmVuZGw7IAogIH0KICB+VmFsdWVUeXBlKCkgCiAgeyAKICAgIHN0ZDo6Y2VyciA8PCAi
ZGVzdHJ1Y3RpbmcgICBWYWx1ZVR5cGUgIiA8PCB0aGlzIDw8IHN0ZDo6ZW5kbDsgCiAgfQogIFZh
bHVlVHlwZShjb25zdCBWYWx1ZVR5cGUgJnYpCiAgewogICAgc3RkOjpjZXJyIDw8ICJjb3B5IGNv
bnN0cnVjdCBWYWx1ZVR5cGUgIiAKCSAgICAgIDw8IHRoaXMgPDwgIiBzcmM6ICIgPDwgJnYgIDw8
IHN0ZDo6ZW5kbDsKICB9Cn07CgpzdHJ1Y3QgQmFzZSAKewogIHZpcnR1YWwgfkJhc2UoKSB7fQog
IHZpcnR1YWwgdm9pZCBieVZhbHVlQ2FsbCggVmFsdWVUeXBlICkgPSAwOwp9OwoKc3RydWN0IERl
cml2ZWQgOiBwdWJsaWMgdmlydHVhbCBCYXNlIAp7CiAgdmlydHVhbCB+RGVyaXZlZCgpIHt9Cn07
CgpzdHJ1Y3QgQmFzZURlZiA6IHB1YmxpYyB2aXJ0dWFsIEJhc2UgCnsKICB2aXJ0dWFsIH5CYXNl
RGVmKCkge30KICB2b2lkIGJ5VmFsdWVDYWxsKCBWYWx1ZVR5cGUgKTsKfTsKCnN0cnVjdCBEZXJp
dmVkRGVmIDogcHVibGljIERlcml2ZWQsIHB1YmxpYyBCYXNlRGVmIAp7Cn07Cgp2b2lkIEJhc2VE
ZWY6OmJ5VmFsdWVDYWxsKCBWYWx1ZVR5cGUgdikKewp9CgoKaW50IG1haW4oaW50IGFyZ2MsIGNo
YXIgKmFyZ3ZbXSkKewogIEJhc2UgKmIgPSBuZXcgRGVyaXZlZERlZjsKICBiLT5ieVZhbHVlQ2Fs
bCggVmFsdWVUeXBlKCkgKTsKICByZXR1cm4gMDsKfQoK


             reply	other threads:[~2001-11-14  2:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-02  8:08 jamie [this message]
2002-04-09 10:16 jason
2002-12-07 13:54 reichelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011114021842.18845.qmail@sourceware.cygnus.com \
    --to=jamie@turbolabs.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).