This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
ambiguous class template instantiation
- From: Adrian Sandor <aditsu at yahoo dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 10 Oct 2003 09:52:47 -0700 (PDT)
- Subject: ambiguous class template instantiation
Hello
I found a problem when trying to compile a piece of
code. I simplified it to this:
template<class T1, class T2=int>struct s1{};
template<class T>struct s2{};
template<template<class>class C, class T>struct
s2<C<T> >{};
template<template<class, class>class C, class T1,
class T2>struct s2<C<T1, T2> >{};
s2<s1<int> >x1;
here's the compiler output:
g++.exe -c test.cpp -o test.o
-I"C:/progs/Dev-Cpp/include/c++"
-I"C:/progs/Dev-Cpp/include/c++/mingw32" -pedantic
-Wall -W -Wno-long-long -fmessage-length=0
test.cpp:5: ambiguous class template instantiation for
`struct s2<s1<int, int> >'
test.cpp:4: candidates are: struct s2<C<T1, T2> >
test.cpp:3: struct s2<C<T> >
test.cpp:5: aggregate `s2<s1<int, int> > x1' has
incomplete type and cannot be defined
test.cpp:5: storage size of `x1' isn't known
the compiler used is gcc 3.2 (mingw)
I also confirmed this problem on a gcc 3.2.2 (linux)
I tested the same code at
http://www.dinkumware.com/exam/ using different
compilers and there was no error
I'd like to know if this is fixed in later versions of
gcc (which versions?)
I also found some similar reports in the mailing
lists, but they're slightly different, so I don't know
if it's the same problem
best regards,
Adrian
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com