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 signed 32-bit integer signed shift left by 31 #3318

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

BsAtHome
Copy link
Contributor

@BsAtHome BsAtHome commented Feb 4, 2025

Integers are 32 bit by default. Performing left shift of 31 on signed integers is undefined by the standard because it is an overflow condition. This happens in statements like 1 << 31. The fix is to state them as unsigned: 1u << 31.

@andypugh
Copy link
Collaborator

andypugh commented Feb 4, 2025

Good catch.

@andypugh andypugh merged commit bba8485 into LinuxCNC:master Feb 4, 2025
10 checks passed
@BsAtHome
Copy link
Contributor Author

BsAtHome commented Feb 4, 2025

Found by cppcheck...

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

Successfully merging this pull request may close these issues.

2 participants