Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xmh0511 opened this issue Jan 4, 2022 · 2 comments
Open

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

xmh0511 opened this issue Jan 4, 2022 · 2 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jan 4, 2022

[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 "".

@frederick-vs-ja
Copy link
Contributor

I think P2361 will resolve this issue.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jan 4, 2022

I think P2361 will resolve this issue.

It seems P2361 still didn't interpret the implicitly added \0. Reference the quote in P2361

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'.

Presumably, the constituent of user-defined-string-literal remains no change in P2361. Also, the constituent of an unevaluated-string is still string-literal. The core issue is that we didn't specify that \0 will add to the end of a string-literal in the current draft as well as in P2361.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants