Title
Evaluation of odr-use
Status
review
Section
6.9.3.3 [basic.start.dynamic]
Submitter
Brian Bi

Created on 2023-12-01.00:00:00 last changed 3 months ago

Messages

Date: 2024-01-21.13:42:21

CWG 2024-01-19

Since "odr-use" is a category error here, use the term "non-initialization use" instead.

Possible resolution:

  1. Change in 6.3 [basic.def.odr] paragraph 6 through 8 as follows:

    A structured binding is odr-used if it appears as by a potentially-evaluated expression E if it is named by E.

    *this is odr-used if this appears as a potentially-evaluated expression (including as the result of the implicit transformation in the body of a non-static member function (11.4.3 [class.mfct.non.static])).

    A virtual member function is odr-used if it is not pure. A function is odr-used by if it is named by a potentially-evaluated expression or conversion E if it is named by E. A non-placement allocation or deallocation function for a class is odr-used by the definition of a constructor of that class. A non-placement deallocation function for a class is odr-used by the definition of the destructor of that class, or by being selected by the lookup at the point of definition of a virtual destructor (11.4.7 [class.dtor]). [ Footnote: ... ]

  2. Change in 6.9.3.3 [basic.start.dynamic] paragraph 4 through 7 as follows:

    A non-initialization odr-use use of an entity is the evaluation of an expression that odr-uses an odr-use (6.3 [basic.def.odr]) the entity where the evaluation is not caused directly or indirectly by the initialization of a non-block static or thread storage duration variable.

    ...If it is deferred, it strongly happens before any non-initialization odr-use use of any non-inline function or non-inline variable defined in the same translation unit as the variable to be initialized. [ Footnote: ... ] ... [ Example: ... It is implementation-defined whether either a or b is initialized before main is entered or whether the initializations are delayed until a is first odr-used used in main. In particular, if a is initialized before main is entered, it is not guaranteed that b will be initialized before it is odr-used used by the initialization of a, that is, before A::A is called. If, however, a is initialized at some point after the first statement of main, b will be initialized prior to its use in A::A. -- end example ]

    ... If it is deferred, it strongly happens before any non-initialization odr-use use of that variable. ...

    ... If it is deferred, the initialization associated with the entity for thread t is sequenced before the first non-initialization odr-use use by t of any non-inline variable with thread storage duration ...

Date: 2024-01-21.13:42:21

Proposed resolution [SUPERSEDED]:

  1. Change in 6.3 [basic.def.odr] paragraph 6 through 8 as follows:

    A structured binding is odr-used if it appears as by a potentially-evaluated expression E if it is named by E.

    *this is odr-used if this appears as a potentially-evaluated expression (including as the result of the implicit transformation in the body of a non-static member function (11.4.3 [class.mfct.non.static])).

    A virtual member function is odr-used if it is not pure. A function is odr-used by if it is named by a potentially-evaluated expression or conversion E if it is named by E. A non-placement allocation or deallocation function for a class is odr-used by the definition of a constructor of that class. A non-placement deallocation function for a class is odr-used by the definition of the destructor of that class, or by being selected by the lookup at the point of definition of a virtual destructor (11.4.7 [class.dtor]). [ Footnote: ... ]

  2. Change in 6.9.3.3 [basic.start.dynamic] paragraph 4 as follows:

    A non-initialization odr-use of an entity is the evaluation of an expression that odr-uses an odr-use (6.3 [basic.def.odr]) the entity where the evaluation is not caused directly or indirectly by the initialization of a non-block static or thread storage duration variable.
Date: 2023-12-01.00:00:00

The concept of odr-use is a static program property, independent of runtime control flow. For example,

void f() {
  if (false)
    g();          // unconditionally odr-uses g
}

Yet, some parts of the standard talk about an odr-use participating in the happens-before relation, which is a category error.

History
Date User Action Args
2024-01-21 13:42:21adminsetmessages: + msg7578
2023-12-16 00:18:01adminsetstatus: open -> review
2023-12-02 21:45:52adminsetmessages: + msg7542
2023-12-01 00:00:00admincreate