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

[C++ codegen] Remove use of the u8"" string literal prefix #2854

Merged
merged 1 commit into from
Sep 10, 2020

Conversation

nburles
Copy link

@nburles nburles commented Jun 22, 2020

Prior to C++20, the type of a "UTF-8 encoded string literal" is char const * - i.e. it is exactly the same as a non-prefixed string literal (they are semantically different, but technically the same).

Since C++20, the type of a UTF-8 encoded string literal is changed to char8_t const * - which is not convertable to char const *. Even in C++20, there is no actual change to how characters are stored, only the type is changed (they are now semantically different, and supposed to be technically different - but nothing in the language actually uses the semantics).

In short, removing the u8"" prefix has no effect prior to C++20, and simply allows compilation to succeed since C++20.

Fixes #2844

Prior to C++20, the type of a "UTF-8 encoded string literal" is char
const * - i.e. it is exactly the same as a non-prefixed string literal
(they are semantically different, but technically the same).

Since C++20, the type of a UTF-8 encoded string literal is changed to
char8_t const * - which is not convertable to char const *.  Even in
C++20, there is no actual change to how characters are stored, only the
type is changed (they are now semantically different, and supposed to be
technically different - but nothing in the language actually uses the
semantics).

In short, removing the u8"" prefix has no effect prior to C++20, and
simply allows compilation to succeed since c++20.
Copy link
Member

@mike-lischke mike-lischke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with that. Looks like a left over to me.

@mike-lischke
Copy link
Member

@parrt Small C++ change, ready to be merged.

@parrt parrt merged commit 2b119be into antlr:master Sep 10, 2020
@parrt parrt added this to the 4.9 milestone Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C++20 can not construct a std::string with a UTF-8 encoded string literal
3 participants