Bug 14284 - [3.4/4.0 regression] Failure to select obvious template specialisation
Summary: [3.4/4.0 regression] Failure to select obvious template specialisation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 critical
Target Milestone: 3.4.0
Assignee: Giovanni Bajo
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
 
Reported: 2004-02-25 01:49 UTC by Niall Douglas
Modified: 2004-10-30 21:11 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.4
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-02-25 17:33:28


Attachments
Preprocessor output causing bug (20.47 KB, application/octet-stream)
2004-02-25 01:50 UTC, Niall Douglas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Niall Douglas 2004-02-25 01:49:29 UTC
GCC v3.4 CVS 20040218: Obviously the zero based specialisation should be chosen 
here, not an ambiguous choice error. It even says so itself:

g++ -fPIC -Wformat -Wno-reorder -Wno-non-virtual-dtor -march=i486 
-mcpu=athlon-xp -fexceptions -fkeep-inline-functions -g -DFOXDLL -DUSE_POSIX 
-DHAVE_CONSTTEMPORARIES -D_DEBUG -DHAVE_XSHM_H -DHAVE_XCURSOR_H=1 -DHAVE_XFT_H=1 
-DXTHREADS=1 -DFOX_THREAD_SAFE=1 -DHAVE_LIBDL=1 -DHAVE_CUPS_H=1 -DSTDC_HEADERS=1 
-DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 
-DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 
-DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_SYS_WAIT_H=1 
-DHAVE_DIRENT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_SELECT_H=1 
-DBUILDING_TCOMMON -DFOXDLL_EXPORTS -DHAVE_JPEG_H -DHAVE_PNG_H -DHAVE_TIFF_H 
-DHAVE_ZLIB_H -DHAVE_OPENSSL -DHAVE_GL_H -DSUN_OGL_NO_VERTEX_MACROS 
-DHPOGL_SUPPRESS_FAST_API -DHAVE_GLU_H -ITnFOX/include -I/usr/kerberos/include 
-I/usr/X11R6/include -I/usr/include/freetype2 -Iinclude -c -o 
objs/Debug/THelpString.os src/THelpString.cxx
`-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.
TnFOX/include/FXGenericTools.h: In constructor `FX::Generic::Bind::Impl<pars, 
fn>::Impl(P1) [with P1 = FX::FXString*, int pars = 1, fn = void (*)(FX::
FXString*)]':
TnFOX/include/FXGenericTools.h:1582:   instantiated from `FX::Generic::
BoundFunctor<typename FX::Generic::FnInfo<fn>::asList>* FX::Generic::
BindFuncN(fn, P1) [with fn = void (*)(FX::FXString*), P1 = FX::FXString*]'
src/THelpString.cxx:85:   instantiated from here
TnFOX/include/FXGenericTools.h:1542: error: ambiguous class template 
instantiation for `struct FX::Generic::TL::InstantiateHelperH::findType<FX::
Generic::TL::instantiateH<FX::Generic::TL::item<FX::FXString*, FX::Generic::
NullType>, FX::Generic::TL::instanceHolderH>, 0>'
TnFOX/include/FXGenericTools.h:698: error: candidates are: struct FX::Generic::
TL::InstantiateHelperH::findType<FX::Generic::TL::instantiateH<typelist, 
instance>, i>
TnFOX/include/FXGenericTools.h:693: error:                 struct FX::Generic::
TL::InstantiateHelperH::findType<FX::Generic::TL::instantiateH<typelist, 
instance>, 0>
TnFOX/include/FXGenericTools.h:1542: error: no matching function for call to 
`instance(FX::Generic::TL::instantiateH<FX::Generic::TL::item<FX::FXString*, FX:
:Generic::NullType>, FX::Generic::TL::instanceHolderH>&)'
scons: *** [objs/Debug/THelpString.os] Error 1

Cheers,
Niall
Comment 1 Niall Douglas 2004-02-25 01:50:20 UTC
Created attachment 5794 [details]
Preprocessor output causing bug
Comment 2 Wolfgang Bangerth 2004-02-25 16:46:19 UTC
I'm reducing this right now. 
 
W. 
 
Comment 3 Wolfgang Bangerth 2004-02-25 17:33:27 UTC
OK, this was a little tougher than thought, but it's clear: 
--------------------- 
template<typename> struct S; 
template<typename, template<class> class> struct I {}; 
 
template<class, int> struct Match; 
 
template<typename T, template<class> class C> 
struct Match<I<T,C>, 0> {}; 
 
template<typename T, template<class> class C, int i> 
struct Match<I<T,C>, i> {}; 
 
Match<I<int,S>, 0> v;  
---------------------- 
This should certainly compile: 
 
g/x> /home/bangerth/bin/gcc-3.3.4-pre/bin/c++ -c x.cc 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
x.cc:12: error: ambiguous class template instantiation for `struct 
Match<I<int, S>, 0>' 
x.cc:10: error: candidates are: struct Match<I<T, C>, i> 
x.cc:7: error:                 struct Match<I<T, C>, 0> 
x.cc:12: error: aggregate `Match<I<int, S>, 0> v' has incomplete type and 
cannot be defined 
x.cc:12: error: storage size of `v' isn't known 
 
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc 
x.cc:12: error: ambiguous class template instantiation for `struct 
Match<I<int, S>, 0>' 
x.cc:10: error: candidates are: struct Match<I<T, C>, i> 
x.cc:7: error:                 struct Match<I<T, C>, 0> 
x.cc:12: error: aggregate `Match<I<int, S>, 0> v' has incomplete type and 
cannot be defined 
x.cc:12: error: storage size of `v' isn't known 
 
 
Comment 4 Giovanni Bajo 2004-02-26 14:02:48 UTC
Mine.
Comment 5 Giovanni Bajo 2004-02-26 17:39:57 UTC
Patch posted:
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg02499.html
Comment 6 GCC Commits 2004-02-26 20:46:15 UTC
Subject: Bug 14284

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	giovannibajo@gcc.gnu.org	2004-02-26 20:46:09

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: ttp8.C 

Log message:
	PR c++/14284
	* pt.c (dependent_type_p_r): A template template parameter is a
	dependent type.
	
	PR c++/14284
	* g++.dg/template/ttp8.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3971&r2=1.3972
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.831&r2=1.832
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3544&r2=1.3545
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ttp8.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 8 Giovanni Bajo 2004-02-27 01:40:35 UTC
Fixed in GCC 3.4.0 and GCC 3.5.0. Thanks for your report!