public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: russ@amc.com (Russell Browne)
To: regan_russell@hotmail.com, gcc@gcc.gnu.org
Subject: Re: I would like to contribute
Date: Fri, 30 Jun 2000 11:50:00 -0000	[thread overview]
Message-ID: <200006301850.LAA04754@coho.amc.com> (raw)

Regan Russell wrote:
	
> Hi, I would like to contribute to gcc.
> I would like you to suggest a small project
> otherwise, I will look for the simplest
> problem in the bug list and investigate it.
	
Here is a suggestion I have contemplated making for several years.

When a C++ destructor is called, the destructor sets the vtable for
the object under destruction to the vtable for the destructor's class,
so that any virtual function calls go to that class's function rather
than that for a subclass that has now been destroyed.

This can be useful information when debugging if one is using a debugger
such as GDB or UPS that shows the vtable symbolically; if the vtable
shows that the class for an object is the base class of what it
ought to be the most likely cause is that you are looking at an object
that has been destroyed.  But this debugging trick does not work if the
object you are looking at is already supposed to be of either the base class
or a subclass.

Now my suggestion:  When compiled with debugging and without optimization,
the final step in a destructor for a base class, or for a class whose base
class does not have virtual functions, should be to set the vtable to a
distinctive value.  Possible values might be 0, 0xdeadbeaf, or to a symbol
that demangles to something like "destoyed object vtable".  If the last
approach, which I like best, is taken, implement such a vtable with the
first 100 or so entries going to a function that prints a message to
stderr and aborts.

Russ Browne
Applied MicroSystems Corp.

             reply	other threads:[~2000-06-30 11:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-30 11:50 Russell Browne [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-06-29 16:35 Regan Russell
2000-06-30  0:10 ` Martin v. Loewis

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=200006301850.LAA04754@coho.amc.com \
    --to=russ@amc.com \
    --cc=gcc@gcc.gnu.org \
    --cc=regan_russell@hotmail.com \
    /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).