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
undefined behavior sanitizer dislikes (1 << 31) #153
Labels
bug
Something isn't working
Milestone
Comments
Huh, thanks @bhaller. Ah, the compiler is right here, |
Simple solution is just use 1<<30, no big deal. |
Yeah, it shifts into the sign bit. Probably unsigned should be used for all flag values, since one never really wants to be carrying flags around in signed ints... |
Yeah, that's true. |
jeromekelleher
added a commit
to jeromekelleher/kastore
that referenced
this issue
Nov 21, 2021
jeromekelleher
added a commit
to jeromekelleher/kastore
that referenced
this issue
Nov 21, 2021
jeromekelleher
added a commit
to jeromekelleher/kastore
that referenced
this issue
Nov 21, 2021
jeromekelleher
added a commit
to jeromekelleher/kastore
that referenced
this issue
Nov 21, 2021
jeromekelleher
added a commit
to jeromekelleher/kastore
that referenced
this issue
Nov 22, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UndefinedBehaviorSanitizer complains:
kastore.c:654:46: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
The relevant line:
if (self->file != NULL && (self->flags & OWN_FILE)) {
The relevant define:
#define OWN_FILE (1 << 31)
The
1
here should be unsigned, I guess, or a shift of less than 31 should be used. I didn't realize that this was undefined behavior in C, but apparently it is?The text was updated successfully, but these errors were encountered: