Skip to content

[dcl.array] Clarify "numbered 0 to N-1" #556

Description

@eisenwave

Reference (section label): [dcl.array]

Discussion (Mattermost): https://chat.isocpp.org/general/pl/3gzbcx4fy3dgjpyno7hkejuksa

Issue description

[dcl.array] p6 states:

An object of type “array of N U” consists of a contiguously allocated non-empty set of N subobjects of type U, known as the elements of the array, and numbered 0 to N-1.

It is not sufficiently clear what "numbered 0 to N-1" means. [basic.compound] Note 5 states that an array has the same address as its first element, relying on this sentence, but it's not clear from normative wording that the first element is found at offset 0 and the last element is found at offset N-1.

In general, "numbered" doesn't strictly imply an ordering from first to last, "to be numbered" has no defined meaning, and the use of "set" instead of "sequence" implies that no particular order is enforced.

Suggested resolution

Update [dcl.array] p6 as follows:

An object
+a
of type “array of N U” consists of a contiguously allocated non-empty
-set
+sequence
of N subobjects of type U, known as the elements of the array
-, and numbered 0 to N-1.
+. The elements of the array, from first to last,
+may be accessed using the expressions a[0] through a[N-1] ([expr.sub]).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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