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

David Carlton carlton@kealia.com
Mon Nov 24 17:23:00 GMT 2003


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



More information about the Gdb-patches mailing list