This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14479] New: enum definition in template class with template methods causes error.
- From: "robertk at mathematik dot uni-freiburg dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Mar 2004 10:00:30 -0000
- Subject: [Bug c++/14479] New: enum definition in template class with template methods causes error.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
GCC Version:
3.3.3
System type:
i386-linux ( SuSE Linux 8.1, kernel 2.4.19 )
options given when GCC was configured/built:
--prefix=path (no system path)
complete command line that triggers the bug:
g++ error.cc
source code that triggers the bug:
---------------------------------------------------------------------------
#include <iostream>
template <int dim, template <int> class T>
class X {
public:
// this enum definition causes problems with g++ 3.3.3
// if enum is not defined, no problems with g++
// if the enum definition is made, then in the specialization
// of the template member method of the class A one template <>
// has to be removed to compile with g++, but then the code is not
// ISO standard anymore
enum { dimension = dim };
typedef T<dim> TType;
template<int d>
int bar ()
{
return asImp().template bar<d> ();
}
private:
// Barton Nackman
T<dim> & asImp()
{
return static_cast<T<dim> &> (*this);
}
};
template <int dim>
class A : public X<dim,A>
{
public:
template<int d>
int bar () ;
};
template <int dim>
template <int d>
inline int A<dim>::bar ()
{
return d;
}
// if the enum definition above is made then g++ only compiles this code
// if the second template <> is removed, but then the code is not ISO standard
// anymore
template <>
template <>
inline int A<0>::bar<0> ()
{
return -1;
}
template<int dim, template <int> class T>
void foo (X<dim,T> & g)
{
std::cout << g.template bar<0> () << "\n";
}
int main ()
{
A<0> a;
foo(a);
A<2> b;
foo(b);
}
---------------------------------------------------------------------------
--
Summary: enum definition in template class with template methods
causes error.
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: robertk at mathematik dot uni-freiburg dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14479