Created on 2004-01-04.00:00:00 last changed 130 months ago
[Voted into WP at August, 2010 meeting.]
Proposed resolution (June, 2010):
Change 13.8.3 [temp.dep] paragraph 1 as follows:
...In an expression of the form:
postfix-expression ( expression-listopt )
where the postfix-expression is an
unqualified-idid-expression, theunqualified-idid-expression denotes a dependent name ifand only ifany of the expressions in the expression-list is a type-dependent expression (13.8.3.3 [temp.dep.expr]) or if the unqualified-id of the id-expression is a template-id in which any of the template arguments depends on a template parameter. If an operand of an operator is a type-dependent expression, the operator also denotes a dependent name. Such names are unbound and are looked up at the point of the template instantiation (13.8.4.1 [temp.point]) in both the context of the template definition and the context of the point of instantiation.
Change 13.8.4.2 [temp.dep.candidate] paragraph 1 as follows:
For a function call that depends on a template parameter,
if the function name is an unqualified-id or if the function is called using operator notation,the candidate functions are found using the usual lookup rules (6.5.3 [basic.lookup.unqual], 6.5.4 [basic.lookup.argdep], 6.5.5 [basic.lookup.qual]) except that:
For the part of the lookup using unqualified name lookup (6.5.3 [basic.lookup.unqual]) or qualified name lookup (6.5.5 [basic.lookup.qual]), only function declarations from the template definition context are found.
For the part of the lookup using associated namespaces (6.5.4 [basic.lookup.argdep]), only function declarations found in either the template definition context or the template instantiation context are found.
If the function name is an unqualified-id and the call would be ill-formed or would find a better match had the lookup within the associated namespaces considered all the function declarations with external linkage introduced in those namespaces in all translation units, not just considering those declarations found in the template definition and template instantiation contexts, then the program has undefined behavior.
Notes from the March 2004 meeting:
A related issue is a call with a qualified name and dependent arguments, e.g., x::y(depa, depb).
Is this program valid?
template <typename T> int g(int); class h{}; template <typename T> int l(){h j; return g<T>(j);} template <typename T> int g(const h&); class j{}; int jj(){return l<j>();}
The key issue is when "g" is looked up, i.e., whether both overloaded template "g" functions are available at the call site or only the first. Clearly, the entire postfix-expression "g<T>(j)" is dependent, but when is the set of available template functions determined?
For consistency with the rules about when the set of available overloads is determined when calling a function given by an unqualified-id, I would think that we should postpone determining the set of template functions if (and only if) any of the explicit template arguments are dependent.
John Spicer: I agree that there should be a core issue for this. The definition of "dependent name" (13.8.3 [temp.dep] paragraph 1) should probably be modified to cover this case. It currently only handles cases where the function name is a simple identifier.
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-03-03 00:00:00 | admin | set | status: fdis -> c++11 |
2011-04-10 00:00:00 | admin | set | status: wp -> fdis |
2010-11-29 00:00:00 | admin | set | status: dr -> wp |
2010-08-23 00:00:00 | admin | set | messages: + msg2925 |
2010-08-23 00:00:00 | admin | set | status: review -> dr |
2010-02-16 00:00:00 | admin | set | messages: + msg2558 |
2010-02-16 00:00:00 | admin | set | status: drafting -> review |
2004-04-09 00:00:00 | admin | set | messages: + msg982 |
2004-04-09 00:00:00 | admin | set | status: open -> drafting |
2004-01-04 00:00:00 | admin | create |