Closed
Description
The type_overflow
lint does not catch integral literals larger than i64::MAX
. I have to assume the problem is the overflow happens when generating the AST, and the lint operates on the AST, so it can't tell that it overflowed.
Example:
println!("{}", 9223372036854775808i64);
// prints -9223372036854775808
println!("{}", 18446744073709551615i64);
// prints -1
It does manage to catch 18446744073709551616
, which is a parse error ("int literal is too large"). This is u64::MAX + 1
, so the parser can definitively tell it's too large even though it doesn't know which integral type is being used.