Skip to content

[over.literal] p1 is out-date #5180

@xmh0511

Description

@xmh0511

[over.literal] p1

The string-literal or user-defined-string-literal in a literal-operator-id shall have no encoding-prefix and shall contain no characters other than the implicit terminating '\0'.

we didn't say a character \0 will implicitly add to the end of a string-literal in the current draft. Instead, we say
[lex.string] p10

String literal objects are initialized with the sequence of code unit values corresponding to the string-literal's sequence of s-chars (originally from non-raw string literals) and r-chars (originally from raw string literals), plus a terminating U+0000 NULL character, in order as follows

Also, [lex.string] p9 says

Evaluating a string-literal results in a string literal object with static storage duration ([basic.stc]).

I think "string-literal" in literal-operator-id is not an expression, there is no evaluation in this context, I believe. [lex.string] p10 is different with [lex.string] p12 in the c++20 standard:

After any necessary concatenation, in translation phase 7 ([lex.phases]), '\0' is appended to every string-literal so that programs that scan a string can find its end.

The above provision is arbitrarily applied to any "string-literal". So, [over.literal] p1 may be correct on this way in the current draft

The string-literal or the string-literal of the user-defined-string-literal in a literal-operator-id shall have no encoding-prefix and the string-literal shall be "".

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