LemonCondor opened a new pull request, #1680:
URL: https://github.com/apache/arrow-go/pull/1680

   ### Rationale for this change
   
   `compute.Divide` with overflow checking on (the default, 
`ArithmeticOptions{}`) returns the minimum value for `min / -1` on signed 
integers. For example, int32 `-2147483648 / -1` returns `-2147483648` with no 
error. The true result does not fit in the type, so the checked kernel should 
report an overflow. The other checked kernels (`add`, `subtract`, `multiply`, 
`negate`, `abs`) already do, and Arrow C++ `divide_checked` returns "overflow" 
for this case.
   
   ### What changes are included in this PR?
   
   The checked integer division kernel now returns the existing `overflow` 
error when a signed dividend is the type's minimum and the divisor is -1. 
Unchecked division keeps Go's wrapping result.
   
   ### Are these changes tested?
   
   Yes. `TestDivideOverflow` in `BinaryIntegralArithmeticSuite` covers int8, 
int16, int32 and int64 with overflow checks on (error expected) and off 
(wrapped value expected). It fails on main: "An error is expected but got nil". 
With the change, `go test -run 'TestBinaryArithmetic$' ./arrow/compute` passes 
on linux/arm64.
   
   ### Are there any user-facing changes?
   
   Yes. Checked `divide` now returns an error for signed `min / -1`, where it 
used to return a wrong value silently.
   
   An AI assistant was used to find and write this change. The added test fails 
without the fix and passes with it.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to