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]

Failed to instanciate template referencing type within other template



Hi,
The attached program fails to compile with a 2.95.3 as well as the most
recent CVS version. This used to work with older egcs version IIRC.

The problem is, that gcc fails to see the template instantiation
opportunity in this case, maybe because the 'inner'-type the second
template refers to couldn't be resolved at template parse time.

Or is this not correct C++ ?  I should get myself the standards ..

ciao,
 -hen
/*
 * provided by Henner Zeller <hzeller@to.com>
 */

// template with inner type
template <class T>
class foo {
public:
	class inner {
	};
};

template <class T>
void process (foo<T>::inner &x) {
}

int main () {
	foo<int>::inner x;
	
	/*
	 * the following yields
	 *     no matching function for call to `process (foo<int>::inner &)'
	 */
	process(x);
}
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.95.3/specs
gcc version 2.95.3 19991030 (prerelease)
 /usr/lib/gcc-lib/i386-redhat-linux/2.95.3/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 -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ templateBug.cc /tmp/cc9gLIwJ.ii
GNU CPP version 2.95.3 19991030 (prerelease) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc-lib/i386-redhat-linux/2.95.3/../../../../include/g++-3
 /usr/local/include
 /usr/lib/gcc-lib/i386-redhat-linux/2.95.3/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /usr/lib/gcc-lib/i386-redhat-linux/2.95.3/../../../../i386-redhat-linux/include
End of omitted list.
 /usr/lib/gcc-lib/i386-redhat-linux/2.95.3/cc1plus /tmp/cc9gLIwJ.ii -quiet -dumpbase templateBug.cc -version -o /tmp/ccs0MTLi.s
GNU C++ version 2.95.3 19991030 (prerelease) (i386-redhat-linux) compiled by GNU C version 2.95.3 19991030 (prerelease).
templateBug.cc: In function `int main()':
templateBug.cc:24: no matching function for call to `process (foo<int>::inner &)'

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