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

2024-09-25


2170. Unclear definition of odr-use for arrays

Section: 6.3  [basic.def.odr]     Status: CD5     Submitter: Hubert Tong     Date: 2015-09-02

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

The current definition of odr-use of a variable is problematic when applied to an array:

A variable x whose name appears as a potentially-evaluated expression ex is odr-used by ex unless applying the lvalue-to-rvalue conversion (7.3.2 [conv.lval]) to x yields a constant expression (7.7 [expr.const]) that does not invoke any non-trivial functions and, if x is an object, ex is an element of the set of potential results of an expression e, where either the lvalue-to-rvalue conversion (7.3.2 [conv.lval]) is applied to e, or e is a discarded-value expression (Clause 7 [expr]).

Consider an example like

  struct S {
    constexpr static const int arr[3] = { 0, 1, 2 };
  };
  int i = S::arr[1];  // Should not require S::arr to be defined

Although the “set of potential results” test correctly handles the subscripting operation (since the resolution of issue 1926), it requires applying the lvalue-to-rvalue conversion to S::arr itself and not just to the result of the subscripting operation. Class objects exhibit a similar problem.

Proposed resolution (January, 2019):

This issue is resolved by the resolution of issue 2083.