This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/56421] Non-matching overload produces template substitution error


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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-22 18:47:55 UTC ---
(In reply to comment #5)
> Function templates must not be instantiated unless the number of arguments
> match.

Where does the standard say that?


> [C++11: 13.3/2]:
> 
> - First, a subset of the candidate functions (those that have the proper number
> of arguments and meet certain other conditions) is selected to form a set of
> viable functions (13.3.2).

You've quoted this out of context, the preceding sentence says "But, once the
candidate functions and argument lists have been identified, the selection of
the best function is the same in all cases:" 

i.e. identifying the candidate functions happens before considering the number
of arguments.

13.3.1 describes how the set of candidate functions (including function
template specializations) is found, then 13.3.2 describes how the number of
arguments is considered in order to find the subset of candidate functions that
are viable.

Also see 14.8.3 [temp.over]/1 "The complete set of candidate functions includes
all the synthesized declarations and all of the non-template overloaded
functions of the same name."

"The complete set" is the set *before* the number of arguments is considered to
find the viable subset. To synthesize the declaration Foo<int>::type must be
known, and that type results in an error.

That's how I read it anyway, I guess I'll leave this for someone else to
interpret.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]