Skip to content

US 1-028 5.3p3 [lex.charset] Allow more characters in an n-char sequence #473

@wg21bot

Description

@wg21bot

The n-char grammar term is defined to match only the Latin uppercase, Latin digit, hyphen and space characters. This results in \N{ABC} matching named-universal-character while \N{abc} does not. This leads to programs like the following being unexpectedly well-formed because the \N{abc} sequence is lexed as the preprocessing token sequence , N, {, abc, }. The expansion of macro a then leads to the token sequence being passed as an argument to macro z where it is discarded.

  #define z(x) 0
  #define a z(
  int x = a\N{abc});

Changes to make the above program ill-formed would provide two benefits:
1. Implementations could diagnose the \N{abc} sequence as an ill-formed named-universal-character regardless of where it appears in a program.
The \N{…} syntax space would be reserved for expansion (e.g., for extensions or future support of UAX44-LM2 loose matching schemes).

Proposed change:
Change the definition of n-char to match the lexing behavior of other delimited character sequences like basic-c-char for character literals and basic-s-char, r-char, and d-char for string literals.
n-char:
any member of the translation character set except the U+007D RIGHT CURLY BRACKET or new-line character

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions