Skip to content

forward-compatible use of u8"..." strings - #39264

Closed
yfeldblum wants to merge 1 commit into
react:mainfrom
yfeldblum:export-D48908076
Closed

forward-compatible use of u8"..." strings#39264
yfeldblum wants to merge 1 commit into
react:mainfrom
yfeldblum:export-D48908076

Conversation

@yfeldblum

Copy link
Copy Markdown
Contributor

Summary:
X-link: facebook/hermes#1113

Since C++20, the type of a u8"..." string literal is const char8_t[N] whereas prior to C++20 the type is const char[N]. char8_t has the same size, alignment, and signedness as unsigned char but is a different type from unsigned char, as well as being a different type from signed char and from char.

In context, the uses of the u8"..." expect const char* (to which const char[N] decays) and not const char8_t* (to which const char8_t[N] decays). To fit the string to the context since C++20, we must reinterpret_cast to const char*; this is a type-level no-op prior to C++20.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D48908076

@facebook-github-botfacebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 1, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D48908076

@analysis-bot

analysis-bot commented Sep 1, 2023

Copy link
Copy Markdown
PlatformEngineArchSize (bytes)Diff
androidhermesarm64-v8a8,966,383+2
androidhermesarmeabi-v7an/a--
androidhermesx86n/a--
androidhermesx86_64n/a--
androidjscarm64-v8a9,558,436+7
androidjscarmeabi-v7an/a--
androidjscx86n/a--
androidjscx86_64n/a--

Base commit: 7a0d2a0
Branch: main

yfeldblum added a commit to yfeldblum/hermes that referenced this pull request Sep 1, 2023
Summary:
X-link: react/react-native#39264
Since C++20, the type of a `u8"..."` string literal is `const char8_t[N]` whereas prior to C++20 the type is `const char[N]`. `char8_t` has the same size, alignment, and signedness as `unsigned char` but is a different type from `unsigned char`, as well as being a different type from `signed char` and from `char`.
In context, the uses of the `u8"..."` expect `const char*` (to which `const char[N]` decays) and not `const char8_t*` (to which `const char8_t[N]` decays). To fit the string to the context since C++20, we must `reinterpret_cast` to `const char*`; this is a type-level no-op prior to C++20.
Changelog: [Internal]
Reviewed By: christophpurrer
Differential Revision: D48908076
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D48908076

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D48908076

yfeldblum added a commit to yfeldblum/hermes that referenced this pull request Sep 2, 2023
Summary:
X-link: react/react-native#39264
Since C++20, the type of a `u8"..."` string literal is `const char8_t[N]` whereas prior to C++20 the type is `const char[N]`. `char8_t` has the same size, alignment, and signedness as `unsigned char` but is a different type from `unsigned char`, as well as being a different type from `signed char` and from `char`.
In context, the uses of the `u8"..."` expect `const char*` (to which `const char[N]` decays) and not `const char8_t*` (to which `const char8_t[N]` decays). To fit the string to the context since C++20, we must `reinterpret_cast` to `const char*`; this is a type-level no-op prior to C++20.
Changelog: [Internal]
Reviewed By: christophpurrer
Differential Revision: D48908076
Summary:
X-link: facebook/hermes#1113
Since C++20, the type of a `u8"..."` string literal is `const char8_t[N]` whereas prior to C++20 the type is `const char[N]`. `char8_t` has the same size, alignment, and signedness as `unsigned char` but is a different type from `unsigned char`, as well as being a different type from `signed char` and from `char`.
In context, the uses of the `u8"..."` expect `const char*` (to which `const char[N]` decays) and not `const char8_t*` (to which `const char8_t[N]` decays). To fit the string to the context since C++20, we must `reinterpret_cast` to `const char*`; this is a type-level no-op prior to C++20.
Changelog: [Internal]
Reviewed By: christophpurrer
Differential Revision: D48908076
yfeldblum added a commit to yfeldblum/hermes that referenced this pull request Sep 2, 2023
Summary:
X-link: react/react-native#39264
Since C++20, the type of a `u8"..."` string literal is `const char8_t[N]` whereas prior to C++20 the type is `const char[N]`. `char8_t` has the same size, alignment, and signedness as `unsigned char` but is a different type from `unsigned char`, as well as being a different type from `signed char` and from `char`.
In context, the uses of the `u8"..."` expect `const char*` (to which `const char[N]` decays) and not `const char8_t*` (to which `const char8_t[N]` decays). To fit the string to the context since C++20, we must `reinterpret_cast` to `const char*`; this is a type-level no-op prior to C++20.
Changelog: [Internal]
Reviewed By: christophpurrer
Differential Revision: D48908076
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D48908076

facebook-github-bot pushed a commit to facebook/hermes that referenced this pull request Sep 2, 2023
Summary:
X-link: react/react-native#39264
Pull Request resolved: #1113
Since C++20, the type of a `u8"..."` string literal is `const char8_t[N]` whereas prior to C++20 the type is `const char[N]`. `char8_t` has the same size, alignment, and signedness as `unsigned char` but is a different type from `unsigned char`, as well as being a different type from `signed char` and from `char`.
In context, the uses of the `u8"..."` expect `const char*` (to which `const char[N]` decays) and not `const char8_t*` (to which `const char8_t[N]` decays). To fit the string to the context since C++20, we must `reinterpret_cast` to `const char*`; this is a type-level no-op prior to C++20.
Changelog: [Internal]
Reviewed By: christophpurrer
Differential Revision: D48908076
fbshipit-source-id: e68d8fc4ff9dfb9528846901e37e2775c2b98866
@facebook-github-botfacebook-github-bot added the Merged This PR has been merged. label Sep 2, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been merged in 041f459.

facebook-github-bot pushed a commit to facebook/hermes that referenced this pull request Nov 8, 2023
Summary:
Original Author: yfeldblum@meta.com
Original Git: f5bf171
Original Reviewed By: christophpurrer
Original Revision: D48908076
X-link: react/react-native#39264
Pull Request resolved: #1113
Since C++20, the type of a `u8"..."` string literal is `const char8_t[N]` whereas prior to C++20 the type is `const char[N]`. `char8_t` has the same size, alignment, and signedness as `unsigned char` but is a different type from `unsigned char`, as well as being a different type from `signed char` and from `char`.
In context, the uses of the `u8"..."` expect `const char*` (to which `const char[N]` decays) and not `const char8_t*` (to which `const char8_t[N]` decays). To fit the string to the context since C++20, we must `reinterpret_cast` to `const char*`; this is a type-level no-op prior to C++20.
Changelog: [Internal]
Reviewed By: tmikov
Differential Revision: D50992883
fbshipit-source-id: e2f126485d80f6f2e1f5c6bcfabbabd53fe01b85
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.fb-exportedMergedThis PR has been merged.p: FacebookPartner: FacebookPartner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@yfeldblum@facebook-github-bot@analysis-bot