This one has a serious flaw:
http://dflund.se/~john_e/gems/gem0032.html
The neg (two's complement) of 0x80000000 is 0x80000000. Thus his trick results in an infinite loop for the most negative value.
The neg (two's complement) of 0x80000000 is 0x80000000. Thus his trick results in an infinite loop for the most negative value.
For what it's worth, my copy of the C11 spec says
The abs, labs, and llabs functions compute the absolute value of an integer j. If the result cannot be represented, the behavior is undefined. 304)
304) The absolute value of the most negative number cannot be represented in two’s complement.