From d4f7c853ae26bb5827868baf0fd2380ce0997478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 20 Jan 2020 19:00:46 +0100 Subject: [PATCH] Math: make Constants::inf() work with clang-cl 8. Using a similar workaround as for nan(). It works with version 9 tho. --- src/Magnum/Math/Constants.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Math/Constants.h b/src/Magnum/Math/Constants.h index 523b099fd..9bbc2bc06 100644 --- a/src/Magnum/Math/Constants.h +++ b/src/Magnum/Math/Constants.h @@ -173,7 +173,7 @@ template<> struct Constants { static constexpr Double sqrt3() { return 1.7320508075688773; } static constexpr Double sqrtHalf() { return 0.7071067811865475; } - static constexpr Double nan() { + static constexpr Double nan() { /* For some reason the NAN macro is not constexpr when using clang-cl, but the builtin (which is used in std::numeric_limits) is. According to the test, NAN is constexpr when using MSVC itself, except on MSVC @@ -184,7 +184,14 @@ template<> struct Constants { return Double(NAN); #endif } - static constexpr Double inf() { return HUGE_VAL; } + static constexpr Double inf() { + /* Same as above, but only for clang-cl 8. 9 has that fixed */ + #if defined(CORRADE_TARGET_CLANG_CL) && __clang_major__ < 9 + return __builtin_huge_val(); + #else + return HUGE_VAL; + #endif + } }; template<> struct Constants { Constants() = delete; @@ -201,7 +208,7 @@ template<> struct Constants { static constexpr Float sqrt3() { return 1.732050808f; } static constexpr Float sqrtHalf() { return 0.707106781f; } - static constexpr Float nan() { + static constexpr Float nan() { /* For some reason the NAN macro is not constexpr when using clang-cl, but the builtin (which is used in std::numeric_limits) is. According to the test, NAN is constexpr when using MSVC itself, except on MSVC @@ -212,7 +219,14 @@ template<> struct Constants { return NAN; #endif } - static constexpr Float inf() { return HUGE_VALF; } + static constexpr Float inf() { + /* Same as above, but only for clang-cl 8. 9 has that fixed */ + #if defined(CORRADE_TARGET_CLANG_CL) && __clang_major__ < 9 + return __builtin_huge_valf(); + #else + return HUGE_VALF; + #endif + } }; #endif