Function std::flags::enable_panic_on_unsafe_math
pub fn enable_panic_on_unsafe_math()
Expand description
Enables the default panic-on-unsafe-math
behavior in the FuelVM.
Additional Information
Note:
panic-on-unsafe-math
is the default, so there is no need to use this function unless you have previously calleddisable_panic_on_unsafe_math
.
Examples
use std::{assert::assert, flags::{disable_panic_on_unsafe_math, enable_panic_on_unsafe_math}, registers::error};
fn main() {
disable_panic_on_unsafe_math();
// Division by zero is considered unsafe math.
let bar = 1 / 0;
// Error flag is set to true whenever unsafe math occurs. Here represented as 1.
assert(error() == 1);
enable_panic_on_unsafe_math();
}