Skip to content

CWG2590 [dcl.enum] Underlying type of enum should determine its size and alignment requirement #39

@t3nsor

Description

@t3nsor

Full name of submitter: Brian Bi

Reference (section label): [dcl.enum]

Issue description: [dcl.enum] explains how the underlying type of an enumeration is determined, and for scoped enumerations, specifies that the enumeration has the same set of values as the underlying type. I'm quite sure that it was intended that the enumeration has the same size and alignment requirement as its underlying type, but the current wording does not explicitly state this. I'm less sure of whether (analogously to [basic.fundamental]/6) it was intended that enumerations always have the same value representation as their underlying type and that every valid value of the enumeration always has the same representation as it does in the underlying type. I think the answer to both is "yes" because otherwise it would be hard to satisfy [dcl.enum]/9 (according to which identity of underlying types is sufficient for layout-compatibility). If so, it should be made explicit. If not, perhaps it would be appropriate to add a note indicating what is not guaranteed.

Suggested resolution: Insert the following paragraph after [dcl.enum]/8:

An enumeration has the same size, value representation, and alignment requirements ([basic.align]) as its underlying type. Furthermore, each value of an enumeration has the same representation as the same value of the underlying type.

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