This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/22364] New: Problems with friend function injection and destructor
- From: "cxl at ntllib dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jul 2005 11:18:25 -0000
- Subject: [Bug c++/22364] New: Problems with friend function injection and destructor
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This code does not compile:
template <class T>
struct Feature {
friend void AssertFeature0(T *) {}
};
template <class T>
inline void AssertFeature(T *t = 0) { if(t) AssertFeature0(t); }
template <class T>
struct Test : Feature< Test<T> >
{
int i;
~Test() { AssertFeature<T>(); }
};
struct Foo : Feature<Foo> { int x; };
void foo()
{
Test< Test<Foo> > 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<Foo> 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