edponce edited a comment on pull request #10274:
URL: https://github.com/apache/arrow/pull/10274#issuecomment-840258476


   @cyb70289  I noticed that *clang* removes the check of `if (result < 0)` 
because it seems that during the analysis it has a rule that the result of 
`std::abs()` is never negative, but this is not true if the input is 
`std::numeric_limits<T>::min()`. In other words, it does not considers the 
overflow case, although the value returned by `std::abs()` is negative. See 
https://godbolt.org/z/7bsM4oTMG to observe this effect. I also tested the 
godbolt example using unknown values at compile-time and observe the same 
behavior. This behavior is observed across compilers. My conclusion is to 
follow the form of `abs_2()`, that is, `if (arg == 
std::numeric_limits<T>::min())`.


-- 
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.

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


Reply via email to