From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10423 invoked by alias); 24 Sep 2004 13:01:25 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 10415 invoked by uid 48); 24 Sep 2004 13:01:22 -0000 Date: Fri, 24 Sep 2004 13:01:00 -0000 Message-ID: <20040924130122.10414.qmail@sourceware.org> From: "bangerth at dealii dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040924081036.17648.hs@profiforms.de> References: <20040924081036.17648.hs@profiforms.de> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/17648] [3.3 regression] template destructor was not called for inherited classes X-Bugzilla-Reason: CC X-SW-Source: 2004-09/txt/msg02925.txt.bz2 List-Id: ------- Additional Comments From bangerth at dealii dot org 2004-09-24 13:01 ------- Nevermind, I see it now -- one has to actually run the test. So here is a reduced testcase: ----------------------- #include extern "C" void abort (); int counter = 0; template struct ListT { ListT() { ++counter; std::cout << "constructor\n"; array=NULL; } ~ListT() { --counter; std::cout << "destructor\n"; if(array) delete array; } T *array; }; class Object; class ObjectList : public ListT {}; class Object { ObjectList list; }; void test() { Object Test; } int main() { test(); if (counter != 0) abort (); } ---------------------------------- This works just fine with gcc 2.95.3, 3.2.3, 3.4.2 and mainline, but it fails with 3.3.4 for which we get only one call to the constructor but none for the destructor. The actual bug in the compiler seems to be rather sensitive to what is actually going on in ListT::~ListT. Maybe someone with more time on their hands can find a shorter testcase without includes. As for workarounds: if you move around some code, I can make the bug in the compiler go away. You may be able to achieve the same in your original code. Apart from that, many thanks for a nice and small testcase, even if I didn't see at first what the problem was :-( Thanks Wolfgang -- What |Removed |Added ---------------------------------------------------------------------------- Known to fail| |3.3.4 Known to work|4.0.0 |4.0.0 3.2.3 2.95.3 3.4.2 Last reconfirmed|0000-00-00 00:00:00 |2004-09-24 13:01:19 date| | Summary|template destructor was not |[3.3 regression] template |called for inherited classes|destructor was not called | |for inherited classes Target Milestone|--- |3.3.5 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17648