public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "eric+sourceware at vangyzen dot net" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug c++/13342] insufficient memory is fetched from the inferior for partially destroyed C++ objects
Date: Wed, 02 Nov 2011 15:22:00 -0000	[thread overview]
Message-ID: <bug-13342-4717-RbGlSQtLxO@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-13342-4717@http.sourceware.org/bugzilla/>

http://sourceware.org/bugzilla/show_bug.cgi?id=13342

--- Comment #3 from Eric van Gyzen <eric+sourceware at vangyzen dot net> 2011-11-02 15:22:31 UTC ---
Thanks for looking into this, Tom.

(In reply to comment #2)
> (gdb) up
> #1  0x000000000040078d in Apple::~Apple (this=0x7fffffffe450, 
>     __in_chrg=<value optimized out>) at pr.cc:34
> 34        ~Apple(void) { }
> (gdb) p *this
> $7 = (Fruit) {
>   _vptr.Fruit = 0x400910, 
>   fruit1 = 1, 
>   fruit2 = 2, 
>   fruit3 = 3, 
>   fruit4 = 4
> }

I did exactly what you did.  However, when I did it, $7 was an Apple:

(gdb) p *this
$3 = {
  <Fruit> = {
    _vptr$Fruit = 0x400a10, 
    fruit1 = 1, 
    fruit2 = 2, 
    fruit3 = 3, 
    fruit4 = 4
  }, 
  members of Apple: 
  apple1 = 0, 
  apple2 = 0, 
  apple3 = 0, 
  apple4 = 0
}

(gdb) ptype *this
type = struct Apple : public Fruit {
[snip]

> At the end here I think the dynamic type has changed to Fruit, so this
> is still correct.

True, but the compile-time type in ~Apple is Apple, so I would expect gdb to
show me the whole Apple.  It does this in my case (v7.2), and it shows
incorrect data for the appleN members.

I wonder why it only shows you the Fruit.  Is this a difference between 7.2 and
HEAD?  What happens when you "p *(class Apple *)this" in ~Apple?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


  parent reply	other threads:[~2011-11-02 15:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-25 14:54 [Bug c++/13342] New: " eric+sourceware at vangyzen dot net
2011-10-25 15:16 ` [Bug c++/13342] " eric+sourceware at vangyzen dot net
2011-10-25 15:16 ` eric+sourceware at vangyzen dot net
2011-10-25 15:17 ` eric+sourceware at vangyzen dot net
2011-11-02 14:53 ` tromey at redhat dot com
2011-11-02 15:22 ` eric+sourceware at vangyzen dot net [this message]
2011-11-03 16:57 ` tromey at redhat dot com
2011-11-03 19:17 ` eric+sourceware at vangyzen dot net
2011-11-08 14:17 ` peter.schauer at mytum dot de
2011-11-08 15:51 ` tromey at redhat dot com
2011-11-08 16:39 ` eric+sourceware at vangyzen dot net
2011-11-09 19:24 ` tromey at redhat dot com
2011-11-09 19:50 ` cvs-commit at gcc dot gnu.org
2011-11-09 19:53 ` tromey at redhat dot com
2011-11-09 20:38 ` eric+sourceware at vangyzen dot net

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=bug-13342-4717-RbGlSQtLxO@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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).