Created on 2014-12-03.00:00:00 last changed 33 months ago
Proposed resolution (January, 2019):
Change 7.2.1 [basic.lval] paragraph 11 as follows:
If a program attempts to access the stored value of an object through a glvalue
of other thanwhose type is not similar (7.3.6 [conv.qual]) to one of the following types the behavior is undefined: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]) to the dynamic type of the object,a type that is the signed or unsigned type corresponding to the dynamic type of the object,
a type that is the signed or unsigned type corresponding to a cv-qualified version of the dynamic type of the object,
an aggregate or union type that includes one of the aforementioned types among its elements or non-static data members (including, recursively, an element or non-static data member of a subaggregate or contained union),
a type that is a (possibly cv-qualified) base class type of the dynamic type of the object,a char, unsigned char, or std::byte type.
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]
Change 7.3.6 [conv.qual] paragraph 1 as follows:
A cv-decomposition of a type T is a sequence of cvi and Pi such that T is
“cv0 P0 ··· cvn-1 Pn-1 cvn U” for n
>≥ 0,where...
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.
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]
the dynamic type of the object,
the signed or unsigned type corresponding to the dynamic type of the object, or
a char or unsigned char type.
[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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-02-18 07:47:23 | admin | set | messages: + msg6710 |
2020-12-15 00:00:00 | admin | set | messages: + msg6370 |
2020-12-15 00:00:00 | admin | set | status: drafting -> cd5 |
2015-11-10 00:00:00 | admin | set | messages: + msg5640 |
2014-12-03 00:00:00 | admin | create |