From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22290 invoked by alias); 15 May 2002 08:46:09 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 22244 invoked by uid 71); 15 May 2002 08:46:06 -0000 Date: Wed, 15 May 2002 01:46:00 -0000 Message-ID: <20020515084605.22242.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: jody@ifi.unizh.ch Subject: Re: c++/6006: problem with pure virtual functions and destructord Reply-To: jody@ifi.unizh.ch X-SW-Source: 2002-05/txt/msg00410.txt.bz2 List-Id: The following reply was made to PR c++/6006; it has been noted by GNATS. From: jody@ifi.unizh.ch To: lerdsuwa@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, jody@ifi.unizh.ch, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Cc: Subject: Re: c++/6006: problem with pure virtual functions and destructord Date: Wed, 15 May 2002 10:41:57 +0200 (CEST) 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? (There are implementations of C++ where the virtual function of the derived class is called) Anyway, the gnu implementation of c++ does not match (section 12.7 para3) > [section 12.7 para 3] > ... When a virtual function is called directly or indirectly > from a constructor (including from the mem-initializer for a > data member) or from a destructor, and the object to which > the call applies is the object under construction or destruction, > the function called is the one defined in the constructor or > destructor's own class or in one of its base, but not a function > overriding it in a class derived from the constructor or > destructor's class, or overriding it in one of the other > base classes of the most derived object (1.8). > This paragraph states that if the virtual function is called directly OR INDIRECTLY from a constructor or destructor, then the virtual function of the class itself is called. 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. Thanks Jody Weissmann Computer Science Department University of Zurich Winterthurerstr 190 8057 Zurich Switzerland Phone: +41(0)1 635 43 17 EMail: jody@ifi.unizh.ch