This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc rejects qualified, dependent template names in templates


All recent versions of gcc present a Catch-22 when using qualified,
dependent template names.  First, gcc misinterprets such a name as
a type, then, it turns around and complains that I supplied a type
instead of a template as a template arg.  Here's a test case:


template<template<class> class F> struct bind_int {
	typedef F<int> type;
};
template<class C> struct bind_int_member {
	typedef bind_int<C::tmpl>::type type; // gets bogus error
};
struct X {
	template<class T>
	struct tmpl {
		T value;
	};
};
int main() {
	// Same as:  X::tmpl<int> x;
	bind_int_member<X>::type x;
}


Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/specs
gcc driver version 2.96 19990913 (experimental) executing gcc version 2.95.1
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Wall -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ bug2.cc /tmp/ccWjMivI.ii
GNU CPP version 2.95.1 19990816 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/../../../../include/g++-3
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/../../../../i686-pc-linux-gnu/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/cc1plus /tmp/ccWjMivI.ii -quiet -dumpbase bug2.cc -Wall -version -o /tmp/ccshcSEi.s
GNU C++ version 2.95.1 19990816 (release) (i686-pc-linux-gnu) compiled by GNU C version 2.95.1 19990816 (release).
bug2.cc:6: to refer to a type member of a template parameter,
bug2.cc:6:   use `typename C::tmpl'
bug2.cc:6: type/value mismatch at argument 1 in template parameter list for `template <template <class> F> bind_int<F>'
bug2.cc:6:   expected a class template, got `typename C::tmpl'
bug2.cc:6: ANSI C++ forbids declaration `type' with no type
bug2.cc:6: confused by earlier errors, bailing out

-- 
----------------------------------------------------------------------
Paul Burchard   <burchard@pobox.com>   http://www.pobox.com/~burchard/
----------------------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]