-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Rustc panics on division of f64 and i32 #24138
Comments
minimized: fn main() {
let max = 10;
let total : f64 = 1.0 as f64 / 1000000.0;
println!("Avg: {}", total / max);
} yields
if you remove the fn main() {
let max = 10;
let total : f64 = 1.0 / 1000000.0;
println!("Avg: {}", total / max);
} you get the correct error:
|
It happens if we use |
I hit mostly same ICE when multiplying. Somehow I couldn't get backtraces (if I set RUST_BACKTRACE rustc crashes with Illegal instruction). fn main() {
let x: f32 = 0.0;
let c = x * 1.0;
let q = c as f32 * 1;
}
Looks like this ICE happens when using same operator twice. Doesn't happen if I change one of operators to fn main() {
let x: f32 = 0.0;
let c = x + 1.0;
let q = c as f32 + 1;
}
|
I've run into this problem too. Test case: fn main() {
let foo: f32 = 10.;
let bar = foo / 2.;
bar / 4;
} |
Tried to find a simple example from my horrible scratch code, the code shouldn't compile due to the division of int and float but the compiler panics instead of erroring out.
I tried this code:
I expected to see this happen: warning about the division such as:
That error occurs if you remove the for loop.
Instead, this happened: rustc panicked
Meta
rustc --version --verbose
:Backtrace:
The text was updated successfully, but these errors were encountered: