Movatterモバイル変換


[0]ホーム

URL:


Issue 2020 - WG21 CWG Issues
Title
Inadequate description of odr-use of implicitly-invoked functions
Status
cd5
Section
6.3 [basic.def.odr]
Submitter
Richard Smith

Created on2014-10-08.00:00:00 last changed62 months ago

Messages

msg6346 (view)
Date: 2019-01-15.00:00:00

Proposed resolution (January, 2019):

  1. Change 6.3 [basic.def.odr] paragraph 2 as follows:

  2. An expressionor conversionispotentially evaluated unless it isan unevaluated operand (7.2 [expr.prop]),or a subexpression thereof, or a conversion inan initialization or conversion sequence in such acontext. The set ofpotential results of anexpressione is defined as follows:...
  3. Cbange 6.3 [basic.def.odr] paragraph 3 as follows:

  4. A function isnamed byanexpressionan expression or conversionas follows:

    • A functionwhose name appears in anexpression is named bythatanexpressionor conversion if it is the uniquelookup resultof a name lookup or theselected member of a set of overloaded functions(6.5 [basic.lookup], 12.2 [over.match],12.3 [over.over])in an overload resolutionperformed as part of forming that expression orconversion, unless it is a pure virtual function andeitherits name is notthe expression is not anid-expression namingthe function with anexplicitlyqualifiedname or the expression forms a pointerto member (7.6.2.2 [expr.unary.op]). [Note: Thiscovers taking the address of functions(7.3.4 [conv.func], 7.6.2.2 [expr.unary.op]),calls to named functions (7.6.1.3 [expr.call]),operator overloading (Clause 12 [over]),user-defined conversions (11.4.8.3 [class.conv.fct]),allocation functions forplacementnew-expressions (7.6.2.8 [expr.new]), aswell as non-default initialization(9.5 [dcl.init]). A constructor selected to copyor move an object of class type is considered to be named byan expressionor conversion even if the call isactually elided by the implementation(11.9.6 [class.copy.elision]). —endnote]

    • An allocation or deallocation function fora class is named by anew-expressionif it isthe single matching deallocation function for the allocationfunction selected by o verload resolution, asspecified in 7.6.2.8 [expr.new]and11.4.11 [class.free].

    • A deallocation function for a class is named by adeleteexpressiondelete-expression if it is the selected usualdeallocation function as specified in7.6.2.9 [expr.delete] and11.4.11 [class.free].

  5. Change 6.3 [basic.def.odr] paragraph 7 as follows:

  6. A virtual member function is odr-used if it is not pure. Afunction is odr-used if it is named by apotentially-evaluated expressionor conversion. Anon-placement...
msg5183 (view)
Date: 2019-02-15.00:00:00

[Accepted as a DR at the February, 2019 meeting.]

According to 6.3 [basic.def.odr] paragraph 3,

A function whose name appears as a potentially-evaluatedexpression is odr-used if it is the unique lookup result orthe selected member of a set of overloaded functions(6.5 [basic.lookup], 12.2 [over.match],12.3 [over.over]), unless it is a pure virtualfunction and its name is not explicitlyqualified. [Note: This covers calls to namedfunctions (7.6.1.3 [expr.call]), operator overloading(Clause 12 [over]), user-defined conversions(11.4.8.3 [class.conv.fct]), allocation function forplacement new (7.6.2.8 [expr.new]), as well asnon-default initialization (9.5 [dcl.init]). Aconstructor selected to copy or move an object of class typeis odr-used even if the call is actually elided by theimplementation (11.4.5.3 [class.copy.ctor]). —endnote] An allocation or deallocation function for a classis odr-used by a new expression appearing in apotentially-evaluated expression as specified in7.6.2.8 [expr.new] and 11.4.11 [class.free]. Adeallocation function for a class is odr-used by a deleteexpression appearing in a potentially-evaluated expressionas specified in 7.6.2.9 [expr.delete] and11.4.11 [class.free].

There are a couple of problems with this specification. First,contrary to the note, the names of overloaded operators, conversionfunctions, etc., do not appear in potentially-evaluated expressions,so the normative text does not make the note true. Also, the“as specified in” references do not cover odr-useexplicitly, only the invocation of the functions.

One possible way of addressing these deficiencies would be ablanket rule like,

A function is odr-used if it is invoked by a potentially-evaluatedexpression.

(The existing wording about appearing in a potentially-evaluatedexpression would still be needed for non-call references.)

History
DateUserActionArgs
2020-12-15 00:00:00adminsetmessages: +msg6346
2020-12-15 00:00:00adminsetstatus: drafting -> cd5
2014-10-08 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp