gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Overflow traps

Open philberty opened this issue 3 years ago • 2 comments

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

philberty avatar Feb 14 '22 10:02 philberty

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.

bjorn3 avatar Feb 14 '22 11:02 bjorn3

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.

philberty avatar Feb 14 '22 11:02 philberty