-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add lint for checking exceeding bitshifts #17713 #18206
Conversation
It should be set to deny by default because it's always a logic error. The undefined behaviour issue is entirely separate from the concerns of a lint checking for it statically. |
Should I change the level to Deny? r? |
@hirschenberger: I'll r+ it with the default set to Deny. |
1c73f6a
to
ee5505e
Compare
@thestinger done. |
Perhaps we could spawn an extra lint message on negative shifts? |
@hirschenberger: AFAIK all shifts are currently by |
@thestinger What do you think, should I add a check for negative shifts which also produce undefined behaviour in llvm let x = 1u8 << -2; IL:
If yes, is it a completely new lint or the same with another message? |
@hirschenberger: The handling of indexing and bit shifts is very buggy. The bugs relating to generic integers should be fixed. It doesn't need a lint. |
this does not compile: 1u32 << -1i this compiles, as if it inferred 1u32 << -1 the same problem occurs in indexing |
Ok, then the Problem will solve itself in the Future© |
@thestinger hmm, what about the failing test? it relies on undefined behaviour, I think it is invalid. |
ee5505e
to
4eaa42b
Compare
Fixed failing test |
@thestinger Would you please r+ my fixes? |
4eaa42b
to
e5058a8
Compare
@thestinger Damn, renamed lint. I hope it's now ready to land |
Next try to get this landed, it seems was a buildbot problem |
Shouldn't |
Oh, good hint. Look at the IR for
I'll change my code to catch the equal bits case. 2014-11-03 15:17 GMT+01:00 Benjamin Herr notifications@github.com:
|
Fix: Handle block exprs as modules when finding their parents Fixes rust-lang#18187
Add lint for checking exceeding bitshifts #17713
It also const-evaluates the shift width (RHS) to check more complex shifts like
1u8 << (4+5)
.The lint-level is set to
Warn
but perhaps it must beDeny
as in llvm exceeding bitshifts are undefined as @ben0x539 stated in #17713