foo
is well-formed and bar
is not, this is covered in [c.math.abs]p3:
Remarks: If abs() is called with an argument of type X for which is_unsigned_v
is true and if X cannot be converted to int by integral promotion, the program is ill-formed. [ Note: Arguments that can be promoted to int are permitted for compatibility with C.— end note]
This came about due to LWG defect 2192.
Interesting to note that gcc and clang disagreed on this one for a while.