Closed
Description
The output of the following test case is 18446744073709551615
:
fn main() {
let mut x = -1;
for i in vec![1usize] {
break;
x = i;
}
println!("{}", x);
}
The problem is that x
is inferred as being usize
. However, the -1
initial value cannot be hold in that type, so it overflows/gets transmuted into an usize
.
My expectation is that this should result in a compilation error.
Meta
rustc 1.1.0-beta (cd7d89a 2015-05-16) (built 2015-05-16)
binary: rustc
commit-hash: cd7d89a
commit-date: 2015-05-16
build-date: 2015-05-16
host: x86_64-pc-windows-gnu
release: 1.1.0-beta
Metadata
Metadata
Assignees
Labels
No labels