public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: c++/6006: problem with pure virtual functions and destructord
Date: Wed, 15 May 2002 03:16:00 -0000	[thread overview]
Message-ID: <20020515101603.5767.qmail@sources.redhat.com> (raw)

The following reply was made to PR c++/6006; it has been noted by GNATS.

From: Nathan Sidwell <nathan@acm.org>
To: jody@ifi.unizh.ch
Cc: lerdsuwa@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, 
    nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/6006: problem with pure virtual functions and destructord
Date: Wed, 15 May 2002 11:06:07 +0100

 jody@ifi.unizh.ch wrote:
 > 
 > Hi
 > Is there a particular reason why a a virtual function called
 > in a destructor is the function of this class and not the derived class?
 because the standard says so.
 
 > (There are implementations of C++ where the virtual
 > function of the derived class is called)
 those implementations are buggy.
 
 > In my example, however, the function g() calls the pure virtual
 > function f(). But g() can be called from the destructor of A,
 > without causing a problem.
 neither call 'works'. Drat, someone's borrowed my c++ std, so this is
 from memory. in the dtor of A, the B object is not complete (B's
 dtor has been executed, modulo the bits pertaining to its bases).
 We shouldn't call (non-static) member functions of B, because
 there's no constructed B object for their this pointer to point to.
 The std says, that in this case, virtual functions dispatch to the
 function seen in the definition of the base being ctor'd or dtor'd
 (i.e. what the final overrider would be if that base was the complete
 object).
 
 IIRC, calling a pure virtual function is undefined, so anything can
 happen. g++ 3.0 reports
 6006.cc:37: abstract virtual `virtual void A::f()' called from destructor
 because it can prove that that resolved to a pure virtual. It cannot
 do so for the one embedded in g, but if you executed such a program
 it would fail.
 
 nathan
 
 -- 
 Dr Nathan Sidwell :: Computer Science Department :: Bristol University
            The voices in my head told me to say this
 nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk


             reply	other threads:[~2002-05-15 10:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-15  3:16 Nathan Sidwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-05-15  1:46 jody
2002-05-14  8:46 lerdsuwa
2002-03-19 10:06 jody

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=20020515101603.5767.qmail@sources.redhat.com \
    --to=nathan@acm.org \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@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).