Skip to content

Commit

Permalink
Test return type 'int' only for glibc + cxx03
Browse files Browse the repository at this point in the history
  • Loading branch information
robincaloudis committed Jul 30, 2024
1 parent c9f6d82 commit b92fb05
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions libcxx/test/std/numerics/c.math/cmath.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,15 +705,16 @@ void test_isinf()
static_assert((std::is_same<decltype(std::isinf((float)0)), bool>::value), "");

typedef decltype(std::isinf((double)0)) DoubleRetType;
#if !defined(__linux__) || defined(__clang__)
static_assert((std::is_same<DoubleRetType, bool>::value), "");
#else
#if defined(__GLIBC__) && defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_PREFERRED_OVERLOAD)
// GLIBC < 2.23 defines 'isinf(double)' with a return type of 'int' in
// all C++ dialects. The test should tolerate this when libc++ can't work
// around it.
// around it via `_LIBCPP_PREFERRED_OVERLOAD`, which is only available
// in modern versions of Clang, and not elsewhere.
// See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439
static_assert((std::is_same<DoubleRetType, bool>::value
|| std::is_same<DoubleRetType, int>::value), "");
#else
static_assert((std::is_same<DoubleRetType, bool>::value), "");
#endif

static_assert((std::is_same<decltype(std::isinf(0)), bool>::value), "");
Expand Down Expand Up @@ -791,15 +792,16 @@ void test_isnan()
static_assert((std::is_same<decltype(std::isnan((float)0)), bool>::value), "");

typedef decltype(std::isnan((double)0)) DoubleRetType;
#if !defined(__linux__) || defined(__clang__)
static_assert((std::is_same<DoubleRetType, bool>::value), "");
#else
// GLIBC < 2.23 defines 'isinf(double)' with a return type of 'int' in
#if defined(__GLIBC__) && defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_PREFERRED_OVERLOAD)
// GLIBC < 2.23 defines 'isnan(double)' with a return type of 'int' in
// all C++ dialects. The test should tolerate this when libc++ can't work
// around it.
// around it via `_LIBCPP_PREFERRED_OVERLOAD`, which is only available
// in modern versions of Clang, and not elsewhere.
// See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439
static_assert((std::is_same<DoubleRetType, bool>::value
|| std::is_same<DoubleRetType, int>::value), "");
#else
static_assert((std::is_same<DoubleRetType, bool>::value), "");
#endif

static_assert((std::is_same<decltype(std::isnan(0)), bool>::value), "");
Expand Down

0 comments on commit b92fb05

Please sign in to comment.