Open philberty opened 2 years ago
Does that emit a trap instruction? In rustc with overflow checks enabled the panic handler is called instead. Providing a trap instruction as option in addition to wrapping and calling the panic handler on overflow may be fine though.
I use the word trap, as in to trap the case of when overflow occurs we can amend this to call whatever panic handler we want. I am linking to this code fragment just so we can find the code to call into the internal builtin functions which GCC to get the overflow condition.
GCC has plenty of builtin_overflow functions ADA has overflow traps akin to rust so we should be able to port this function:
https://github.com/Rust-GCC/gccrs/blob/c7275a7fb89f324e7cd7881d12a49287a89f1c74/gcc/ada/gcc-interface/trans.cc#L9531-L9726