Movatterモバイル変換


[0]ホーム

URL:


Issue 2170 - WG21 CWG Issues
Title
Unclear definition of odr-use for arrays
Status
cd5
Section
6.3 [basic.def.odr]
Submitter
Hubert Tong

Created on2015-09-02.00:00:00 last changed62 months ago

Messages

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

Proposed resolution (January, 2019):

This issue is resolved by the resolution ofissue 2083.

msg5633 (view)
Date: 2019-02-15.00:00:00

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

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

A variablex whose name appears as apotentially-evaluated expressionex is odr-usedbyex unless applying the lvalue-to-rvalueconversion (7.3.2 [conv.lval]) tox yields aconstant expression (7.7 [expr.const]) that doesnot invoke any non-trivial functions and, ifx isan object,ex is an element of the set of potentialresults of an expressione, where either thelvalue-to-rvalue conversion (7.3.2 [conv.lval]) isapplied toe, ore is a discarded-valueexpression (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 requireS::arr to be defined

Although the “set of potential results” testcorrectly handles the subscripting operation (since theresolution ofissue 1926), itrequires applying the lvalue-to-rvalue conversion toS::arr itself and not just to the result of thesubscripting operation. Class objects exhibit a similarproblem.

History
DateUserActionArgs
2020-12-15 00:00:00adminsetmessages: +msg6349
2020-12-15 00:00:00adminsetstatus: drafting -> cd5
2015-09-02 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp