overflower icon indicating copy to clipboard operation
overflower copied to clipboard

DONT_PANIC?

Open llogiq opened this issue 9 years ago • 2 comments

I wonder if overflower should have a mode that avoids panics distinct from wrap/saturate to do whatever on overflow (e.g. return 0) but avoid panic.

The rationale is that even with wrap (and as of yet saturate), division/remainder can panic when dividing by zero. I don't want to have different semantics from the original wrapping methods, and saturate is more complex and likely slower.

llogiq avatar Jul 03 '16 11:07 llogiq

It would also be great to have a mode where overflow is undefined behavior. It is quite rare that wrapping where someone didn't expect it will fix a bug so for release builds it would be nice to get some extra performance.

kevincox avatar Oct 31 '16 20:10 kevincox

Agreed, this is something I would like to see. However it would require linking LLVM intrinsics not currently available in Rust, and I lack the time to maintain it.

llogiq avatar Oct 31 '16 21:10 llogiq