Should INT_MIN % -1
return 0 instead of panicking?
#1276
Labels
T-libs-api
Relevant to the library API team, which will review and decide on the RFC.
As @bill-myers originally pointed out here
INT_MIN % -1
is mathematically well-defined to be0
, but Rust currently unconditionally panics instead, as likeINT_MIN / -1
it is technically an overflow according to the two's complement representation. If we're incurring a branch to test for this case anyways, then we might as well return the correct result.("Forked" from #1237.)
The text was updated successfully, but these errors were encountered: