This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch/testsuite/c++] test script for PR c++/186


On Sun, 23 Nov 2003 17:04:45 -0500 (EST), mec.gnu@mindspring.com (Michael Elizabeth Chastain) said:

> The issue is that the user is accessing a destroyed object through a
> pointer.  Because the object has been destroyed, its vptr has been
> degraded to its most primitive base class.  gdb gets confused and
> prints incorrect data, which is always wrong.

I wouldn't necessarily call this incorrect/wrong, but it is somewhat
unfortunate.  I confess, though, that the correct fix isn't at all
obvious to me, given that normally the dynamic type is more useful
than the static type.  Should GDB try to somehow take the supremum of
the static type and the dynamic type?  (And what if there is no
supremum?)  Should GDB try to remember when the user explicitly casts?
(If so, exactly how do we want to remember that?)  Should there be an
option to turn of RTTI usage?  (But users won't know about that.)

Maybe the best thing to do would be as follows, if A is the dynamic
type and B is the static type, then we check to make sure that A is
more specialized than B.  If so, we use A; otherwise, we print a
warning and use B.  I can't remember offhand if we have a way to
calculate whether or not A is more specialized with B, but it
shouldn't be too hard to do.

David Carlton
carlton@kealia.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]