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

Explicit invocation of constructors, destructors and conversion operators in template code



>Submitter-Id:	net
>Originator:	Franck Branjonneau
>Organization:	
>Confidential:	no
>Synopsis:	 
>Severity:	 serious
>Priority:	
>Category:	 c++
>Class:		 ice-on-legal-code, accepts-illegal
>Release:	4.0.1 (Debian 4.0.1-2) (Debian testing/unstable)
>Environment:
System: Linux x86_64 GNU/Linux
Architecture: x86_64
	
host: x86_64-pc-linux-gnu
build: x86_64-pc-linux-gnu
target: x86_64-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --enable-nls --without-included-gettext --enable-threads=posix --program-suffix=-4.0 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk-default --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --enable-checking=release x86_64-linux-gnu
>Description:
	

I've commented the following code with, or whithout (uh!), the errors that g++ reports.

template< typename _Type >
struct S {

 operator S();

}; // struct S< _Type >

template< typename _Type >
struct T {

 S< _Type > t_;
 S< int > i_;

 void
 foo() {

   t_.S();                        // 1.1 uh!
   t_.S< _Type >();               // 1.2
   // i_.S();                        // 1.3 invalid use of `struct S<int>'
   // i_.S< int >();                 // 1.4 internal compiler error: in lookup_member, at cp/search.c:1287

   // t_.~S();                       // 2.1 expected class-name before '(' token
   t_.~S< _Type >();              // 2.2
   i_.~S();                       // 2.3 uh!
   i_.~S< int >();                // 2.4

   // t_.operator S();               // 3.1 `S' is not a type
   t_.operator S< _Type >();      // 3.2
   i_.operator S();               // 3.2 uh!
   i_.operator S< int >();        // 3.4
 }

}; // struct T< _Type >

>How-To-Repeat:
	
>Fix:
	
May be (for 1.4) use a placement new expression.



Reply to: