Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 4861
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: aaw@rincewind.tv
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
gcc-bug.ii.bz2 gcc-bug.ii.bz2 application/octet-stream 2003-05-21 15:16 6.68 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 4861 depends on: Show dependency tree
Show dependency graph
Bug 4861 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2001-11-12 12:16
If a template base class destructor calls a virtual function, the most-derived
version is called.  This contradicts section 12.7 of the ANSI C++ Standard:

Release:
gcc version 2.96 20000731

Environment:
Red Hat Linux 7.1 2.96-98

How-To-Repeat:
The executable compiled from this source prints the sequence of calls to
destructors and virtual function f().  The call sequence is: D::~D(), D::f(),
B::~B(), D::f().  This last one should be B::f().

------- Comment #1 From aaw@rincewind.tv 2001-11-12 14:30 -------
From: "Aloysius A. Wild III" <aaw@rincewind.tv>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, aaw@rincewind.tv,
   gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/4861
Date: Mon, 12 Nov 2001 14:30:58 -0800

 This is a multi-part message in MIME format.
 --------------070207030005010402050701
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4861&database=gcc
 
 I've attached an un-preprocessed source file.  Note that this problem 
 exists in both 3.0.2 and the current 3.1 snapshot.
 
 Ollie
 
 --------------070207030005010402050701
 Content-Type: text/plain;
  name="gcc-bug.cpp"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="gcc-bug.cpp"
 
 #include <iostream>
 
 template<class C> class B {
     public:
         ~B()
         {
             std::cerr << "Running B::~B()" << std::endl;
             f();
         }
 
         virtual void f()
         {
             std::cerr << "Running B::f()" << std::endl;
         }
 };
 
 class D : public B<int> {
     public:
         ~D()
         {
             std::cerr << "Running D::~D()" << std::endl;
             f();
         }
 
         virtual void f()
         {
             std::cerr << "Running D::f()" << std::endl;
         }
 };
 
 int main(int argc, char **argv)
 {
     D d;
 
     return 0;
 }
 
 --------------070207030005010402050701--
 

------- Comment #2 From Nathan Sidwell 2001-12-15 11:31 -------
State-Changed-From-To: open->analyzed
State-Changed-Why: confirmed. Still present in 3.0

------- Comment #3 From Nathan Sidwell 2001-12-28 11:05 -------
State-Changed-From-To: analyzed->closed
State-Changed-Why: fixed in mainline

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug