Skip to content

Unreachable code suppresses warnings #29803

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

Closed
ranma42 opened this issue Nov 12, 2015 · 1 comment
Closed

Unreachable code suppresses warnings #29803

ranma42 opened this issue Nov 12, 2015 · 1 comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@ranma42
Copy link
Contributor

ranma42 commented Nov 12, 2015

println!("{}", false && ((1u8 - 5u8) == 42));

results in "warning: attempted to sub with overflow", but

println!("{}", if false { ((1u8 - 5u8) == 42) } else { false });

compiles with no warning at all.

I would expect both expressions to warn, either because of the overflow or because of dead code (or both).

@steveklabnik steveklabnik added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Nov 12, 2015
@0xmohit
Copy link
Contributor

0xmohit commented Oct 4, 2016

The second example produces warning with 1.12.0 -- https://is.gd/Pz7wkc.

@ranma42 ranma42 closed this as completed Oct 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

3 participants