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

stb_ds: Fix d[i] << 24 undefined behaviour due to overflow #1682

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

Conversation

darkuranium
Copy link

Because of int promotion, d[i] << 24 overflows an int, resulting in UB.

Found via ubsan in clang 18:

stb/stb_ds.h:1124:67: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior stb/stb_ds.h:1124:67

Because of int promotion, `d[i] << 24` overflows an int, resulting in UB.

Found via ubsan in clang 18:
```
stb/stb_ds.h:1124:67: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior stb/stb_ds.h:1124:67
```
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.

1 participant