fix: trap on overflow in i32::checked_div#1168
Conversation
| // TODO(#1162): remove once #1162 is fixed and handle MIN/-1 in `i32_checked_div` above | ||
| /// This test reproduces #1162 | ||
| #[test] | ||
| fn i32_checked_div_min_by_neg1_i1162_reproducer() { |
There was a problem hiding this comment.
Can be removed as the test i32_checked_div now asserts that (i32::MIN, -1) causes a FailedAssertionOverflow trap.
There was a problem hiding this comment.
It is one weighted branch in a randomized prop_oneof!, so a proptest run can pass without executing the exact i32::MIN / -1 case.
There was a problem hiding this comment.
I assumed weights are chosen such that the probability of each case being executed is "high enough". Though your comment made me take another look as this is relevant for all tests that use NumericStrategy. I've opened #1169 to address this. WDYT?
greenhat
left a comment
There was a problem hiding this comment.
Looking good! Please see my comment.
| // TODO(#1162): remove once #1162 is fixed and handle MIN/-1 in `i32_checked_div` above | ||
| /// This test reproduces #1162 | ||
| #[test] | ||
| fn i32_checked_div_min_by_neg1_i1162_reproducer() { |
There was a problem hiding this comment.
It is one weighted branch in a randomized prop_oneof!, so a proptest run can pass without executing the exact i32::MIN / -1 case.
Closes #1162
Stacked on top of #1160 to have access to intrinsic testing.
The intrinsic
i32::checked_divshould trap oni32::MIN/-1because the result overflowsi32. It did not trap because it didn't account for this edge case.