Bug 11154 - [3.3/3.4 regression] spurious ambiguity report for template class specialization
Summary: [3.3/3.4 regression] spurious ambiguity report for template class specialization
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P1 critical
Target Milestone: 3.3.1
Assignee: Kriang Lerdsuwanakij
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2003-06-11 15:47 UTC by lorgon1
Modified: 2004-01-17 04:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-06 11:08:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lorgon1 2003-06-11 15:47:57 UTC
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
Comment 1 Wolfgang Bangerth 2003-06-11 17:56:28 UTC
Confirmed. A regression in 3.3 and mainline.
W.
Comment 2 Andrew 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 6 GCC Commits 2003-07-14 10:09:07 UTC
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

Comment 7 GCC Commits 2003-07-14 10:49:07 UTC
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

Comment 8 Kriang Lerdsuwanakij 2003-07-14 10:50:05 UTC
Fixed in the upcoming 3.3.1 and main trunk.