Hard
Integer overflow in a debug build vs. an optimized build
get_max() returns i32::MAX through std::hint::black_box (so the compiler can't prove the overflow at compile time and constant-fold it away). Compare a plain debug build (rustc main.rs) against an optimized release build (rustc -O main.rs); same source, same x + 1. What does each produce?
main.rs
fn get_max() -> i32 {
std::hint::black_box(i32::MAX)
}
fn main() {
let x: i32 = get_max();
let y = x + 1;
println!("{}", y);
}37 of 53 in Rust