Post

Making all divisions slower to fix a bug in 0.000000000000000000542% of cases

Futhark changed its generated C to avoid undefined behavior when the most-negative signed integer is divided by -1. The fix adds a special case and uses unsigned negation, preserving Futhark’s defined wrapping semantics.

The cost was unmeasurable in the project’s regular benchmarks and CPU microbenchmark, but a deliberately division-bound CUDA test ran about 2.3× slower; the author says typical GPU workloads showed no measurable impact. In the 12-comment Lobsters thread, readers questioned the distinction between treating division by zero as an error and defining overflow behavior; one noted that integer-overflow division has caused security bugs.