[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Problems in instanciation of generic members.



>Submitter-Id:	net-debian
>Originator:	Franck Branjonneau
>Organization:	
>Confidential:	no
>Synopsis:	 Problems in instanciation of generic members.
>Severity:	
serious
>Priority:	
medium
>Category:	 c++
>Class:		
rejects-legal
>Release:	3.0 (Debian) (Debian testing/unstable)
>Environment:
System: Linux alpha.tchume.net 2.4.4 #2 mar mai 22 08:16:07 CEST 2001 i586 unknown
Architecture: i586

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-x --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
>Description:
	
The following code:

template< typename X, typename Y, int = 1 >
struct C1 {
  
  template< int, int >
  struct C2 {
    enum { v = false };
  };
};

enum X { a, b, c, d };

template<>
struct C1< X, X >::C2< a, a > {
  enum { v = true };
};

template< int a >
struct C1< X, X >::C2< a, a > {
  enum { v = true };
};

template< typename X >
struct D: public C1< X, X, 5 > {
  
  template< int a >
  struct C1< X, X, 5 >::C2< a, a > {
    enum { v = true };
  };
};

//template C1< X, X >;
//template D< X >;

#include <iostream>
int main() {
  std::cout << D< X >::C2< a, a >::v << std::endl;
}

gives(from www.codesourcery.com)

GCC Output

These are the results of processing your source code with the following command:

    g++ [input] 


Exit code: 256

Messages:

    /usr/tmp/@4352.7.cc: In instantiation of `C1::C2<0, 0>':
    /usr/tmp/@4352.7.cc:36:   instantiated from here
    /usr/tmp/@4352.7.cc:36: Internal compiler error in tsubst, at cp/pt.c:6376

In my environment, messages are slightly different:

g++-3.0 tmp0.cc  
tmp0.cc: In instantiation of `C1<X, X, 5>::C2<0, 0>':
tmp0.cc:36:   instantiated from here
tmp0.cc:5: Internal compiler error in retrieve_specialization, at cp/pt.c:740

>How-To-Repeat:
	

>Fix:
	

Instanciate explicitely the template ie uncomment:
//template D< X >;

Well, it's compile but I've not verify the resulting code.





Reply to: