Uh oh!
There was an error while loading. Please reload this page.
Add lint for checking exceeding bitshifts #17713 - #18206
Conversation
thestinger
commented
Oct 22, 2014
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. |
hirschenberger
commented
Oct 24, 2014
Should I change the level to Deny? r? |
thestinger
commented
Oct 24, 2014
@hirschenberger: I'll r+ it with the default set to Deny. |
1c73f6a to
ee5505eComparehirschenberger
commented
Oct 24, 2014
@thestinger done. |
hirschenberger
commented
Oct 24, 2014
Perhaps we could spawn an extra lint message on negative shifts? |
thestinger
commented
Oct 24, 2014
@hirschenberger: AFAIK all shifts are currently by |
hirschenberger
commented
Oct 24, 2014
@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? |
thestinger
commented
Oct 24, 2014
@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. |
thestinger
commented
Oct 24, 2014
this does not compile: 1u32 << -1i this compiles, as if it inferred 1u32 << -1 the same problem occurs in indexing |
hirschenberger
commented
Oct 24, 2014
Ok, then the Problem will solve itself in the Future© |
hirschenberger
commented
Oct 25, 2014
@thestinger hmm, what about the failing test? it relies on undefined behaviour, I think it is invalid. |
ee5505e to
4eaa42bComparehirschenberger
commented
Oct 30, 2014
Fixed failing test |
hirschenberger
commented
Oct 31, 2014
@thestinger Would you please r+ my fixes? |
4eaa42b to
e5058a8Comparehirschenberger
commented
Nov 1, 2014
@thestinger Damn, renamed lint. I hope it's now ready to land |
hirschenberger
commented
Nov 2, 2014
Next try to get this landed, it seems was a buildbot problem |
ben0x539
commented
Nov 3, 2014
Shouldn't |
hirschenberger
commented
Nov 3, 2014
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 Fixesrust-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
Warnbut perhaps it must beDenyas in llvm exceeding bitshifts are undefined as @ben0x539 stated in #17713