This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


704. To which postfix-expressions does overload resolution apply?

Section: 12.2.2.2  [over.match.call]     Status: CD2     Submitter: Jens Maurer     Date: 29 July, 2008

[Voted into WP at October, 2009 meeting.]

There are several problems with the phrasing of 12.2.2.2 [over.match.call] paragraphs 1 and 3. Paragraph 1 reads,

Recall from 7.6.1.3 [expr.call], that a function call is a postfix-expression, possibly nested arbitrarily deep in parentheses, followed by an optional expression-list enclosed in parentheses: Overload resolution is required if the postfix-expression is the name of a function, a function template (13.7.7 [temp.fct]), an object of class type, or a set of pointers-to-function.

Aside from the fact that directly addressing the reader (“Recall that...”) is stylistically incongruous with the rest of the Standard, as well as the fact that 7.6.1.3 [expr.call] doesn't mention parentheses at all, this wording does not cover member function calls: a member access expression isn't “the name” of anything. This should perhaps be reworded to refer to being either an id-expression or the id-expression in a member access expression. This could be either by using two lines in the “of the form” citation or in the discussion following the syntax reference.

In addition, paragraph 3 refers to “a postfix-expression of the form &F,” which is an oxymoron: &F is a unary-expression, not a postfix-expression. One possibility would be to explicitly include the parentheses needed in this case, i.e., “a postfix-expression of the form (&F)...”

Proposed resolution (September, 2009):

Replace the entirety of 12.2.2.2 [over.match.call] with the following two paragraphs:

In a function call (7.6.1.3 [expr.call])

if the postfix-expression denotes a set of overloaded functions and/or function templates, overload resolution is applied as specified in 12.2.2.2.2 [over.call.func]. If the postfix-expression denotes an object of class type, overload resolution is applied as specified in 12.2.2.2.3 [over.call.object].

If the postfix-expression denotes the address of a set of overloaded functions and/or function templates, overload resolution is applied using that set as described above. If the function selected by overload resolution is a non-static member function, the program is ill-formed. [Note: The resolution of the address of an overload set in other contexts is described in 12.3 [over.over]. —end note]