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

Fix error: signed shift result #1259

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

r-barnes
Copy link
Contributor

@r-barnes r-barnes commented Jan 17, 2024

Summary

Fixes

hermes/Support/StringTableEntry.h:19:44: error: signed shift result (0x80000000) sets the sign bit of the shift expression's type ('int') and becomes negative [-Werror,-Wshift-sign-overflow]

which allows the -Wshift-sign-overflow flag to be set.

Test Plan

Standard CI

Fixes
```
hermes/Support/StringTableEntry.h:19:44: error: signed shift result (0x80000000) sets the sign bit of the shift expression's type ('int') and becomes negative [-Werror,-Wshift-sign-overflow]
```
which allows the `-Wshift-sign-overflow` flag to be set.
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jan 17, 2024
@@ -16,7 +16,7 @@ namespace hermes {

/// An entry in the string table inside the ConsecutiveStringStorage.
class StringTableEntry {
static constexpr uint32_t UTF16_MASK = 1 << 31;
static constexpr uint32_t UTF16_MASK = static_cast<uint32_t>(1) << 31;
Copy link
Contributor

Choose a reason for hiding this comment

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

We prefer C-style casts for trivial cases like this. (uint32_t)1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants