[Bug c++/47765] Wrong template deduction

jason at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 8 19:23:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47765

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-09-08 18:50:32 UTC ---
(In reply to comment #4)
> In fact I expected that there is some implementation freedom which allows this
> (I was thinking of 14.7.1 p6), but I still wonder: I have always understood
> that 14.8.2 only applies, if *all* template arguments are provided:

"This is done at the beginning of template argument deduction when any
explicitly specified template arguments are substituted into the function type"
seems pretty clear to me that it happens at the beginning and does not require
all parameters to have explicit arguments.

> Doesn't this indicate that
> 
> template<typename T, typename T2>
> void foo(const A<T>& r);
> 
> must be rejected immediately in this case, because T2 is nowhere specified nor
> deducible?

No, it seems to me that the standard specifies that we do deduction on all
parm/arg pairs and only then fail if a template parameter is not deduced; we
don't check ahead of time to see if any parameters are nondeducible.  That
might be a reasonable change given that now some semantics depend on whether or
not a parameter is used in a deducible context, but it isn't what the standard
currently says.



More information about the Gcc-bugs mailing list