[libcxx-commits] [libcxx] [libc++][math] Fix acceptance of convertible types in `std::isnan()` and `std::isinf()` (PR #98952)

Robin Caloudis via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 31 03:21:24 PDT 2024


robincaloudis wrote:

> @robincaloudis The `mathcalls.h` header seems to be part of glibc, which is the C Standard Library on Linux. Not libstdc++, which is the C++ Standard Library (typically) used on Linux. So the setup here is what you would expect: libc++ layered on top of glibc (a C stdlib), and no second C++ stdlib anywhere.
> 
> It looks like the `float`, `double` and `long double` overloads of `std::isnan` have been added in C++11. So I guess what's happening here is that we incorrectly try to provide them and step on the toes of the C Standard Library.
> 
> It looks like libstdc++ ends up providing the `double` overload via a template checking `is_arithmetic`: https://godbolt.org/z/bse6GzEMx. Since templates are less preferred than non-template functions, perhaps this is why libstdc++ doesn't hit the same issue.

@ldionne, thanks for pointing out the obvious! I reconsidered my approach and found a solution. Do you mind to take a look? Thank you.

https://github.com/llvm/llvm-project/pull/98952


More information about the libcxx-commits mailing list