This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17570] New: Extension to incorporate default parameters in signature of templates breaks valid program
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Sep 2004 16:00:50 -0000
- Subject: [Bug c++/17570] New: Extension to incorporate default parameters in signature of templates breaks valid program
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
We have an extension by which a template class X with n parameters can
match a template template parameter with m<n parameters, if X
provides default arguments for the remaining n-m template parameters.
Unfortunately, this extension leads us to reject this (valid) program:
--------------------
template<typename> struct match { };
template<template<typename> class t,typename T>
struct match<t<T> > { typedef int type; };
template<template<typename,typename> class t,typename T0,typename T1>
struct match<t<T0,T1> > { typedef int type; };
template<typename,typename =void> struct other { };
typedef match<other<void,void> >::type type;
---------------------------
g/x> /home/bangerth/bin/gcc-4*/bin/c++ -c x.cc
x.cc:11: error: ambiguous class template instantiation for `struct
match<other<void, void> >'
x.cc:7: error: candidates are: struct match<t<T0, T1> >
x.cc:4: error: struct match<t<T> >
x.cc:11: error: `type' in class `match<other<void, void> >' does not name a
type
I think we should first try to match the two-template parameter version
of "other", and _only if that fails_, try to also use the default argument
and match it against one-parameter template template parameters.
W.
--
Summary: Extension to incorporate default parameters in signature
of templates breaks valid program
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bangerth at dealii dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17570