Issue 204212
Summary [libc++] std::abs does not accept __int128 or signed _BitInt(N)
Labels libc++
Assignees
Reporter xroche
    ## Summary

`std::abs` has no overload for `__int128` or for `_BitInt(N)` (integers with a programmer-chosen bit width). Calling `std::abs` on either does not compile: the call is ambiguous. Both are common types for arithmetic wider than 64 bits, so the gap is easy to hit.

## Reproducer

https://godbolt.org/z/hWKo3xzee

```cpp
#include <cstdlib>
int main() {
    __int128 x = -5;
    return (int)std::abs(x); // error: call to 'abs' is ambiguous
}
```

With no integer overload that fits, the compiler falls back to the `float`, `double`, and `long double` ones and cannot choose between them.

## Fix

PR #196532 adds `std::abs` overloads for `__int128` and signed `_BitInt(N)`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to