This was reported by practicalswift here #18046
It seems that the original author of the line used a reference to glibc abs
: https://github.com/lattera/glibc/blob/master/stdlib/abs.c
However depending on some implementation details this can be undefined behavior for unusual values.
A detailed explanation of the UB is provided here : https://stackoverflow.com/questions/17313579/is-there-a-safe-way-to-get-the-unsigned-absolute-value-of-a-signed-integer-with (by Billy O’Neal)
Simple relevant godbolt example : https://godbolt.org/z/yRwtCG
Thanks!