Skip to content

[clang] Invalid character/string literals accepted in C++ during preprocessing after P2621R2. #107191

Open
@keinflue

Description

@keinflue

After P2621R2, which is a defect report, the following program is ill-formed in C++ (UB beforehand):

#define X '\N'
int main() {}

This is ill-formed already in translation phase 3 when lexing into preprocessing tokens, because \N not followed by { can't be a named-universal-character and \N also can't begin any escape-sequence. Therefore '\N' can't be a character-literal and ' will form a single-character preprocessing token by itself. [lex.pptoken]/2 makes this ill-formed (UB before P2621R2).

The C++ status page claims that P2621R2 is already supported, but Clang compiles this without diagnostic (https://godbolt.org/z/WxvcfPj8a).

The same happens with other invalid escape sequences and string literals as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions