Movatterモバイル変換


[0]ホーム

URL:


Issue 2051 - WG21 CWG Issues
Title
Simplifying alias rules
Status
cd5
Section
7.2.1 [basic.lval]
Submitter
Richard Smith

Created on2014-12-03.00:00:00 last changed48 months ago

Messages

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

Proposed resolution (January, 2019):

  1. Change 7.2.1 [basic.lval] paragraph 11 as follows:

  2. If a program attempts to access the stored value of anobject through a glvalueof other thanwhose type is not similar (7.3.6 [conv.qual])to one of the following types the behavior isundefined:58

    • the dynamic type of the object,

    • a cv-qualified version of the dynamic type of the object,

    • a type similar (as defined in 7.3.6 [conv.qual]) tothe dynamic type of the object,

    • a type that is the signed or unsigned typecorresponding to the dynamic type of the object,

    • a type that is the signed or unsigned typecorresponding to a cv-qualified version of the dynamic typeof the object,

    • an aggregate or union type that includes one of theaforementioned types among its elements or non-static datamembers (including, recursively, an element or non-staticdata member of a subaggregate or contained union),

    • a type that is a (possibly cv-qualified) base class type ofthe dynamic type of the object,

    • achar,unsigned char, orstd::byte type.

    If a program invokes a defaulted copy/move constructoror copy/move assignment operator for a union of typeUwith a glvalue argument that does not denote an object of typecvU within its lifetime, the behavior isundefined. [Note: Unlike in C, C++ has no accesses ofclass type. —end note]

  3. Change 7.3.6 [conv.qual] paragraph 1 as follows:

  4. Acv-decomposition of a typeTis a sequence ofcviandPi such thatT is

      cv0 P0 ··· cvn-1 Pn-1 cvnU” forn> 0,

    where...

msg6370 (view)
Date: 2022-02-18.07:47:23

Additional note, October, 2015:

It has been suggested that the aliasing rules should be extended to permit an object ofan enumeration with a fixed underlying type to alias an object withthat underlying type.

msg5640 (view)
Date: 2022-02-18.07:47:23

Suggested resolution:

Replace 7.2.1 [basic.lval] paragraph 10 as follows:

If a program attempts to access the stored value of an objectthrough a glvalue whose type is not similar (7.3.6 [conv.qual])to one of the following types the behavior is undefined:[Footnote:... —end footnote]

  • the dynamic type of the object,

  • the signed or unsigned type corresponding to the dynamictype of the object, or

  • achar orunsigned char type.

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

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

The aliasing rules of 7.2.1 [basic.lval] paragraph 10 wereadapted from C with additions for C++. However, a number of the pointseither do not apply or are subsumed by other points. For example, theprovision for aggregate and union types is needed in C for structassignment, which in C++ is done via constructors and assignmentoperators in C++, not by accessing the complete object.

History
DateUserActionArgs
2022-02-18 07:47:23adminsetmessages: +msg6710
2020-12-15 00:00:00adminsetmessages: +msg6370
2020-12-15 00:00:00adminsetstatus: drafting -> cd5
2015-11-10 00:00:00adminsetmessages: +msg5640
2014-12-03 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp