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

Should have a lint for statically detectable overlong bit shifts #17713

Closed
ben0x539 opened this issue Oct 2, 2014 · 2 comments
Closed

Should have a lint for statically detectable overlong bit shifts #17713

ben0x539 opened this issue Oct 2, 2014 · 2 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@ben0x539
Copy link
Contributor

ben0x539 commented Oct 2, 2014

Currently overlong bit shifts are undefined behavior because that's how llvm rolls--#10183. But even when they aren't, we should warn on something like x << 24 where x happens to be u8, since it's a useless operation that couldn't possibly return anything interesting.

There's a motivating example and I imagine it'd be a common gotcha since other languages tend to read unadorned integral literals as 32bit ints and then promote the x in x << 24 before doing the actual shift.

@huonw huonw added the A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. label Oct 2, 2014
hirschenberger added a commit to hirschenberger/rust that referenced this issue Nov 1, 2014
bors added a commit that referenced this issue Nov 3, 2014
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 be `Deny` as in llvm exceeding bitshifts are undefined as @ben0x539 stated in #17713
@hirschenberger
Copy link
Contributor

I think this can be closed, resolved in #18206

@ben0x539
Copy link
Contributor Author

ben0x539 commented Nov 4, 2014

Hooray!

@ben0x539 ben0x539 closed this as completed Nov 4, 2014
lnicola pushed a commit to lnicola/rust that referenced this issue Jul 28, 2024
fix: early exit if unresolved field is an index

Fixes rust-lang#17710
RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 1, 2024
fix: early exit if unresolved field is an index

Fixes rust-lang#17710
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

3 participants