Skip to content

CWG1953 [intro.memory] Unsequenced accesses within the same storage are not undefined behavior when different scalar objects are used (unsequenced union access) #621

Closed
cplusplus/draft
#7458
@Eisenwave

Description

@Eisenwave

Reference (section label): [intro.memory]

Issue description

union U { int x, y; } u; (u.x = 1, 0) + (u.y = 2, 0);

The latter statement makes two unsequenced modifications which target the same storage within u but are not the same memory location by definition. Therefore, the statement is well-defined, but it should not be.

Suggested resolution

Update [intro.memory] paragraph 3 as follows:

A memory location is a set of elements which occupy overlapping storage, where each element is either an object of scalar type that is not a bit-field or a maximal sequence of adjacent bit-fields all having nonzero width.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions