To better understand Rusts panic / exclusion mechanisms, I wrote the following code fragment:
extern crate libc;
fn main() {
let mut x: i32;
unsafe {
x = libc::getchar();
}
let y = x - 65;
println!("{}", x);
let z = 1 / y;
println!("{}", z);
}
I wanted to check how Rust works with division by zero cases. Initially, I assumed that he either took the raw SIGFPE in person, or died, or implemented a handler and redirected it to panic (which can be dealt with now?).
The code is verbose because I wanted to make sure that Rust wasnβt doing anything βsmartβ when, at compile time, it knew that something was null, hence user input. Just give him an βA,β and he should do the trick.
, Rust , , . .: -)
: ? , . ? SIGFPE?
Github, .
, " ". ? - ?