EXC_BAD_INSTRUCTION on random Int between Int.min and Int.max
phimage opened this issue · 1 comments
phimage commented
When developing a feature about Lattice (ordered with min and max bound) for RandomKit
https://github.com/phimage/RandomKit/blob/feature-lattice/RandomKit/RandomType.swift
after doing one for my maths project
phimage/Arithmosophi@e4db5e2
an issue occurs.
Doing random on min...max range of a Int (and other type) failed with EXC_BAD_INSTRUCTION
A test to add to check this error
func testRandomIntMax() {
let min = Int.min
let max = Int.max
Int.random(min...max)
}
nvzqz commented
The EXC_BAD_INSTRUCTION
is due to the overflow when subtracting Int.min
from Int.max
. I'm not sure of a way around it.