[Accepted as a DR at the November, 2024 meeting.]
(From submission #548.)
Subclause 7.2.1 [basic.lval] paragraph 11 specifies:
... If a program attempts to access (3.1 [defns.access]) the stored value of an object through a glvalue through which it is not type-accessible, the behavior is undefined. ...
Thus, access (read or write) to an int object using an lvalue of type unsigned int is valid. However, 7.3.2 [conv.lval] bullet 3.4 does not specify the resulting value when, for example, the object contains the value -1:
- Otherwise, the object indicated by the glvalue is read (3.1 [defns.access]), and the value contained in the object is the prvalue result. ...
Similarly, 7.6.19 [expr.assign] paragraph 2 is silent for the assignment case:
In simple assignment (=), the object referred to by the left operand is modified (3.1 [defns.access]) by replacing its value with the result of the right operand.
Any concerns about accesses to the object representation are handled in the context of P1839.