11154 – [3.3/3.4 regression] spurious ambiguity report for template class specialization (original) (raw)

| 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 "" # 1 "" # 1 "tmp.cc" template struct Outer { template <class T, class U = void, class V = void> struct Foo {}; template <class T, class U> struct Foo<T,U,void> {}; template struct Foo<T,void,void> {}; }; Outer::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::Foo<int, void, void>' tmp.cc:5: error: candidates are: struct Outer::Foo<T, void, void> tmp.cc:4: error: struct Outer::Foo<T, U, void> tmp.cc:8: error: aggregate `Outer::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::Foo<int, void, void>' tmp.cc:5: error: candidates are: struct Outer::Foo<T, void, void> tmp.cc:4: error: struct Outer::Foo<T, U, void> tmp.cc:8: error: aggregate `Outer::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 Comment 1 Wolfgang Bangerth 2003-06-11 17:56:28 UTC Confirmed. A regression in 3.3 and mainline. W. Comment 2 Drea Pinski 2003-06-23 23:52:06 UTC It is a regression from 3.2.3. Comment 3 janis187 2003-06-24 19:27:23 UTC 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. Comment 5 Mark Mitchell 2003-07-14 05:32:00 UTC 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 Comment 8 Kriang Lerdsuwanakij 2003-07-14 10:50:05 UTC Fixed in the upcoming 3.3.1 and main trunk. | | | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |