This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14502] New: [3.3 Regression] g++ compile fails "no matching function" using forward declaration of class involving inheritance
- From: "stuart_hc at users dot sourceforge dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Mar 2004 14:56:47 -0000
- Subject: [Bug c++/14502] New: [3.3 Regression] g++ compile fails "no matching function" using forward declaration of class involving inheritance
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
$ cat gccbug.c
template <class T> class BaseClass
{
public:
T* Ptr;
};
template <class T> class TestClass
{
public:
void Func(BaseClass<T> *refcount)
{
}
TestClass()
{
}
TestClass(T * ptr)
{
Func(ptr);
}
TestClass & operator=(T * ptr)
{
Func(ptr);
return *this;
}
};
class DerivedClass;
class DerivedClassTest : public TestClass<DerivedClass>
{
public:
DerivedClassTest() : TestClass<DerivedClass>() { };
DerivedClassTest(DerivedClass * ptr) : TestClass<DerivedClass>(ptr) { };
};
class DerivedClass : public BaseClass<DerivedClass>
{
public:
DerivedClass() {};
};
int main(int, char **)
{
DerivedClassTest Test;
DerivedClass *Ptr = 0;
Test.Func(Ptr);
Test = Ptr;
}
$ g++ gccbug.c
gccbug.c: In constructor `TestClass<T>::TestClass(T*) [with T = DerivedClass]':
gccbug.c:36: instantiated from here
gccbug.c:20: error: no matching function for call to `TestClass<DerivedClass>::
Func(DerivedClass*&)'
gccbug.c:11: error: candidates are: void TestClass<T>::Func(BaseClass<T>*)
[with T = DerivedClass]
g++ versions 3.3, 3.3.1, 3.3.2, 3.3.3 cannot compile this code. g++ 3.1.x and
3.2.x can compile it, so it looks like a 3.3 specific regression.
If the definition of DerivedClass is moved before DerivedClassTest, g++ 3.3.x
does find a matching function for Func.
--
Summary: [3.3 Regression] g++ compile fails "no matching
function" using forward declaration of class involving
inheritance
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: stuart_hc at users dot sourceforge dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14502