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=24139