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 absurd_extreme_comparisons alert for comparison between usize and u64? #1802

Open
BusyJay opened this issue May 29, 2017 · 1 comment
Labels
S-needs-discussion Status: Needs further discussion before merging or work can be started

Comments

@BusyJay
Copy link

BusyJay commented May 29, 2017

let t = i64::MAX;
assert!(t as u64 > usize::MAX as u64);

When compiling above snippet, clippy complains that:

note: #[warn(absurd_extreme_comparisons)] on by default
help: because usize::MAX as u64 is the maximum value for this type, this comparison is always false

It's true on amd64 platform but not true on i686 platform. Alert on this will assume the code is only compiled and run for amd64 target. And all portable code will need to allow absurd_extreme_comparisons explicitly.

@oli-obk oli-obk added the S-needs-discussion Status: Needs further discussion before merging or work can be started label May 29, 2017
@oli-obk
Copy link
Contributor

oli-obk commented May 29, 2017

Since this comparison is useless on 64bit systems, maybe the better solution would be to use some form of cfg to distinguish these cases explicitly. Can you show a real world example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-discussion Status: Needs further discussion before merging or work can be started
Projects
None yet
Development

No branches or pull requests

2 participants