From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23097 invoked by alias); 8 Jul 2005 11:18:38 -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 22603 invoked by uid 48); 8 Jul 2005 11:18:25 -0000 Date: Fri, 08 Jul 2005 11:18:00 -0000 From: "cxl at ntllib dot org" To: gcc-bugs@gcc.gnu.org Message-ID: <20050708111823.22364.cxl@ntllib.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/22364] New: Problems with friend function injection and destructor X-Bugzilla-Reason: CC X-SW-Source: 2005-07/txt/msg00943.txt.bz2 List-Id: This code does not compile: template struct Feature { friend void AssertFeature0(T *) {} }; template inline void AssertFeature(T *t = 0) { if(t) AssertFeature0(t); } template struct Test : Feature< Test > { int i; ~Test() { AssertFeature(); } }; struct Foo : Feature { int x; }; void foo() { Test< Test > test; } ---------------------- The problem seems to be in fact that ~Test destructor is instantiated BEFORE friend is injected and only in the case that templates are nested. Moving AssertFeature to other method (and instatiating) or reducing test-case to just "Test test;" makes code compile fine. Comeau C++ testdrive compiles this code without problems. -- Summary: Problems with friend function injection and destructor Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: cxl at ntllib dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22364