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

2024-12-19


2051. Simplifying alias rules

Section: 7.2.1  [basic.lval]     Status: CD5     Submitter: Richard Smith     Date: 2014-12-03

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

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

Suggested resolution:

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

If a program attempts to access the stored value of an object through 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]

Additional note, October, 2015:

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

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 an object through a glvalue of other than whose type is not similar (7.3.6 [conv.qual]) to one of the following types the behavior is undefined:58

    If a program invokes a defaulted copy/move constructor or copy/move assignment operator for a union of type U with a glvalue argument that does not denote an object of type cv U within its lifetime, the behavior is undefined. [Note: Unlike in C, C++ has no accesses of class type. —end note]

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

  4. A cv-decomposition of a type T is a sequence of cvi and Pi such that T is

    where...