g++-3.3 reports an error (ambiguous template instantiation) for a non-ambiguous case. I have reduced it to a very tiny test program. Preprocessed source file which exposes the bug: pitcairn:/net/hc282/lorgon/FC++/FC++-clients> cat tmp.ii # 1 "tmp.cc" # 1 "<built-in>" # 1 "<command line>" # 1 "tmp.cc" template <class A> struct Outer { template <class T, class U = void, class V = void> struct Foo {}; template <class T, class U> struct Foo<T,U,void> {}; template <class T> struct Foo<T,void,void> {}; }; Outer<int>::Foo<int,void,void> f; int main() { } pitcairn:/net/hc282/lorgon/FC++/FC++-clients> Here is what g++-3.3 has to say: pitcairn:/net/hc282/lorgon/FC++/FC++-clients> g++-3.3 -Wall tmp.cc tmp.cc:8: error: ambiguous class template instantiation for `struct Outer<int>::Foo<int, void, void>' tmp.cc:5: error: candidates are: struct Outer<A>::Foo<T, void, void> tmp.cc:4: error: struct Outer<A>::Foo<T, U, void> tmp.cc:8: error: aggregate `Outer<int>::Foo<int, void, void> f' has incomplete type and cannot be defined tmp.cc:8: error: storage size of `f' isn't known pitcairn:/net/hc282/lorgon/FC++/FC++-clients> The output is wrong; there should be no error. Prior versions of gcc and other compilers get it right. Here is the platform/etc info: Script started on Wed Jun 11 11:36:36 2003 pitcairn:/net/hc282/lorgon/FC++/FC++-clients> g++-3.3 -v -save-temps -Wall tmp.cc Reading specs from /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/lib/gcc-lib/sparc- sun-solaris2.8/3.3/specs Configured with: /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3/configure --prefix=/net/ hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run --program-suffix=-3.3 --enable-threads -- enable-languages=c++ Thread model: posix gcc version 3.3 /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/lib/gcc-lib/sparc-sun-solaris2.8/3.3/ cc1plus -E -D__GNUG__=3 -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 - D__GNUC_PATCHLEVEL__=0 -Dsparc -D__sparc__ -D__sparc - D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc tmp.cc -Wall tmp.ii ignoring nonexistent directory "/net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/sparc- sun-solaris2.8/include" #include "..." search starts here: #include <...> search starts here: /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/include/c++/3.3 /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/include/c++/3.3/sparc-sun-solaris2.8 /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/include/c++/3.3/backward /usr/local/include /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/include /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/lib/gcc-lib/sparc-sun-solaris2.8/3.3/ include /usr/include End of search list. /net/hc282/lorgon/YSPACE/InstallDir/gcc-3.3-run/lib/gcc-lib/sparc-sun-solaris2.8/3.3/ cc1plus -fpreprocessed tmp.ii -quiet -dumpbase tmp.cc -auxbase tmp -Wall -version -o tmp.s GNU C++ version 3.3 (sparc-sun-solaris2.8) compiled by GNU C version 3.3. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 tmp.cc:8: error: ambiguous class template instantiation for `struct Outer<int>::Foo<int, void, void>' tmp.cc:5: error: candidates are: struct Outer<A>::Foo<T, void, void> tmp.cc:4: error: struct Outer<A>::Foo<T, U, void> tmp.cc:8: error: aggregate `Outer<int>::Foo<int, void, void> f' has incomplete type and cannot be defined tmp.cc:8: error: storage size of `f' isn't known pitcairn:/net/hc282/lorgon/FC++/FC++-clients> exit script done on Wed Jun 11 11:37:20 2003
Confirmed. A regression in 3.3 and mainline. W.
It is a regression from 3.2.3.
The regression in 11154 was introduced or exposed by this patch: --- gcc/gcc/cp/ChangeLog --- 2002-05-15 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> PR c++/6620 * pt.c (verify_class_unification): Don't check if PARM is template parameter dependent. Simplify. (unify) [TEMPLATE_PARM_INDEX]: Handle when ARG is a template parameter dependent expression. The regression hunt used the submitter's test case on i686-pc-linux-gnu compiled with no options.
Patch submitted: http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01247.html and http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01246.html
Kriang -- Please rerun the tests on a 3.3 compiler. If they still pass, please check in this change on both 3.3 and mainline. Thanks! -- Mark
Subject: Bug 11154 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: lerdsuwa@gcc.gnu.org 2003-07-14 10:09:03 Modified files: gcc/cp : ChangeLog cp-tree.h pt.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: partial2.C Log message: PR c++/11154 * pt.c (more_specialized_class): Add full_args parameter. (most_specialized_class): Adjust calls to more_specialized_class. * cp-tree.h (more_specialized_class): Adjust declaration. * g++.dg/template/partial2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.182&r2=1.3076.2.183 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.776.2.26&r2=1.776.2.27 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.635.2.32&r2=1.635.2.33 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.230&r2=1.2261.2.231 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/partial2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
Subject: Bug 11154 CVSROOT: /cvs/gcc Module name: gcc Changes by: lerdsuwa@gcc.gnu.org 2003-07-14 10:48:59 Modified files: gcc/cp : ChangeLog cp-tree.h pt.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: partial2.C Log message: PR c++/11154 * pt.c (more_specialized_class): Add full_args parameter. (most_specialized_class): Adjust calls to more_specialized_class. * cp-tree.h (more_specialized_class): Adjust declaration. * g++.dg/template/partial2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3517&r2=1.3518 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.875&r2=1.876 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.723&r2=1.724 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2871&r2=1.2872 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/partial2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
Fixed in the upcoming 3.3.1 and main trunk.