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 undefined behavior #2587

Closed
wants to merge 1 commit into from
Closed

Conversation

MatzeB
Copy link
Contributor

@MatzeB MatzeB commented May 13, 2024

Summary:
For a signed integer type it is undefined behavior in C++ to left-shift bits into the leftmost position where the result would become a negative number.

Rewrite several ((long long)1) << X) expressions to 1ULL << X using unsigned long long to avoid this undefined behavior fixing UBSan complaints. This rewrites all instances of the pattern for consistency (even in places that wouldn't end up shifting into the highest bit position).

Differential Revision: D57281091

@facebook-github-bot
Copy link
Contributor

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

Copy link

netlify bot commented May 13, 2024

Deploy Preview for pytorch-fbgemm-docs failed.

Name Link
🔨 Latest commit 4662133
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/66424232a1576e0008145f13

Summary:

For a signed integer type it is undefined behavior in C++ to left-shift bits into the leftmost position where the result would become a negative number.

Rewrite several `((long long)1) << X)` expressions to `1ULL << X` using unsigned long long to avoid this undefined behavior fixing UBSan complaints. This rewrites all instances of the pattern for consistency (even in places that wouldn't end up shifting into the highest bit position).

Differential Revision: D57281091
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 7792908.

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.

None yet

2 participants