Skip to content

CWG3120 [lex.icon] "the sequence of (grammar term) octal-digits" does not cover the integer literal 0 #794

@morinmorin

Description

@morinmorin

(Originally filed as cplusplus/draft#8380; resubmitting here as a CWG issue, because this is not editorial. With thanks to @eisenwave for the guidance.)

Full name of submitter: Masaki Moriguchi

Reference (section label): [lex.icon]

Issue description:
PR cplusplus/draft#3650 slimmed down [lex.icon] p1 to

In an integer-literal, the sequence of binary-digits, octal-digits, digits, or hexadecimal-digits is interpreted as a base N integer

However, this simplification appears to go a bit too far: in the (octal) integer literal 0, there are no octal-digits following the leading zero; so 0 falls outside this wording.

Decimal-literals have a similar issue: the leading nonzero-digit is not included in "the sequence of digits".

Suggested resolution:
Change in 5.3.2 [lex.icon] paragraph 1 as follows:

In an integer-literal,
the sequence of
- binary-digits,
- octal-digits,
- digits, or
- hexadecimal-digits
+  - binary-digits,
+  - 0 and zero or more octal-digits,
+  - nonzero-digit and zero or more digits, or
+  - hexadecimal-digits
is interpreted as a base N integer

Drafting note: The list is itemized for readability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions