This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/24143] New: Forward declaration of class in template class
- From: "mspencer at ndsuk dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Sep 2005 11:41:37 -0000
- Subject: [Bug c++/24143] New: Forward declaration of class in template class
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
We have code that works with g++ 3.2.3 (i386-redhat-linux) that no longer works
on 4.
#include <iostream>
using namespace std;
template<typename T>
class Hide {
public:
Hide() {
a=new Hidden();
}
class Hidden;
private:
Hidden *a;
};
template<>
class Hide<int>::Hidden
{
public:
Hidden();
};
template<>
Hide<int>::Hidden::Hidden() {
cout << "Hello from int->Hidden" << endl;
}
int main(int argc,char *argv[])
{
Hide<int> b;
}
I get the error:
error: template-id ?Hidden<>? for ?Hide<int>::Hidden<int>::Hidden()? does not
match any template declaration
However, if I remove the Hidden constructor from the code , I get the error:
undefined reference to `Hide<int>::Hidden::Hidden()
I am confused by the Hidden<int> in the first example and think that the
undefined reference error is correct.
--
Summary: Forward declaration of class in template class
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mspencer at ndsuk dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24143