Movatterモバイル変換


[0]ホーム

URL:


Issue 2092 - WG21 CWG Issues
Title
Deduction failure and overload resolution
Status
cd5
Section
13.10.4 [temp.over]
Submitter
Fedor Sergeev

Created on2015-03-06.00:00:00 last changed62 months ago

Messages

msg5875 (view)
Date: 2017-11-15.00:00:00

Proposed resolution (November, 2017)

  1. Change 7.6.1.3 [expr.call] paragraph 1, splittingit into three paragraphs, as follows:

  2. A function call is a postfix expression followed by parentheses containinga possibly empty, comma-separated list ofinitializer-clauses whichconstitute the arguments to the function. The postfix expression shall havefunction type or function pointer type. For a call to a non-member functionor to a static member function, the postfix expression shall be either anlvalue that refers to a function (in which case the function-to-pointerstandard conversion (7.3.4 [conv.func]) is suppressed on the postfixexpression), or it shall have function pointer type.Calling a functionthrough an expression whose function type is different from the functiontype of the called function's definition results in undefined behavior(9.12 [dcl.link]).

    For a call to a non-static member function, the postfix expression shallbe an implicit (11.4.3 [class.mfct.non.static], 11.4.9 [class.static])or explicit class member access (7.6.1.5 [expr.ref]) whoseid-expression is a function member name, or a pointer-to-memberexpression (7.6.4 [expr.mptr.oper]) selecting a function member; the callis as a member of the class object referred to by the object expression. Inthe case of an implicit class member access, the implied object is the onepointed to bythis. [Note: A member function call of theformf() is interpreted as(*this).f() (see11.4.3 [class.mfct.non.static]). —end note]

    If a function or member function name is used,the name can beoverloaded (Clause 12 [over]), in which case theappropriate functionshall be selectedand the validity ofthe call are determined according to the rules in12.2 [over.match]. If the selected function is non-virtual, or iftheid-expression in the class member access expression is aqualified-id, that function is called. Otherwise, its final overrider(11.7.3 [class.virtual]) in the dynamic type of the object expression iscalled; such a call is referred to as avirtual functioncall. [Note: The dynamic type is the type of the object referredto by the current value of the object expression. 11.9.5 [class.cdtor]describes the behavior of virtual function calls when the object expressionrefers to an object under construction or destruction. —endnote]

  3. Add the following to 7.6.1.3 [expr.call] as a new paragraphbefore the existing paragraph 4:

  4. Calling a function through an expression whose function type is different from the function type of the called function's definition results in undefined behavior (9.12 [dcl.link]).

    When a function is called, each parameter (9.3.4.6 [dcl.fct])shall be initialized...

  5. Change Clause 12 [over] paragraph 2 as follows:

  6. Whenan overloadeda function name is used in a call,whichoverloaded function declaration is beingreferencedisand the validity of the call aredetermined by comparing the types of the arguments at the point of use withthe types of the parameters in theoverloaded declarations thatare visible at the point of use. This function selection process iscalledoverload resolution...
  7. Change 13.10.4 [temp.over] paragraph 1 as follows:

  8. A function template can be overloaded either by (non-template)functions of its name or by (other) function templates of the samename. When a call tothatthe nameof afunction or function template is written (explicitly, or implicitlyusing the operator notation), template argument deduction...

This resolution also resolvesissue 2241.

msg5563 (view)
Date: 2015-05-15.00:00:00

Notes from the May, 2015 meeting:

This issue is mostly a duplicate ofissue 1582. However, CWG felt that itshould be clarified that overload resolution applies in all cases,not just when templates are overloaded, so the issue is being leftopen to deal with that aspect.

msg5562 (view)
Date: 2018-03-15.00:00:00

[Accepted as a DR at the March, 2018 (Jacksonville) meeting.]

Given an example like

  template <class T = int> void foo(T*);  void test()  {    foo(0);   // #1 valid?    foo<>(0);  // #2 valid?  }

most/all implementations reject this code. However, the wordingof the Standard only invokes 13.10.4 [temp.over](“Overload resolution”) in cases where there is morethan one function or function template, which is not the case here.The current wording would appear to make this well-formed becauseof the application of 13.10.2 [temp.arg.explicit] paragraph 2.Perhaps overload resolution should apply even when there is a singlefunction template?

History
DateUserActionArgs
2020-12-15 00:00:00adminsetstatus: dr -> cd5
2018-04-11 00:00:00adminsetstatus: tentatively ready -> dr
2018-02-27 00:00:00adminsetmessages: +msg5875
2018-02-27 00:00:00adminsetstatus: drafting -> tentatively ready
2017-02-06 00:00:00adminsetstatus: open -> drafting
2015-05-25 00:00:00adminsetmessages: +msg5563
2015-03-06 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp