-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_copysign cannot be used in constant context (MSVC 16 2019) #20
Comments
Unfortunately, your approach does not cover signed zeros - try If MSVC's |
template <typename T>
constexpr bool signbit(const T x) noexcept
{
#if defined(__clang__) || defined(__GNUC__)
return __builtin_signbit(x);
#else
static_assert(sizeof(T) == 4 || sizeof(T) == 8);
using uint = std::conditional_t<sizeof(T) == 4, std::uint32_t, std::uint64_t>;
return std::bit_cast<uint>(x) & (uint{ 1 } << (sizeof(T) * 8 - 1));
#endif
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Building GCEM in a project using Cmake on Windows 10, and with MSVC 16 2019 as the compiler fails, it appears that the implementation of _copysign cannot be used in a constant context. Many errors were thrown of the form:
The same code compiled fine when using GCC.
I've confirmed that the errors are removed by manually implementing a version of copysign:
#gcem_options.hpp
The text was updated successfully, but these errors were encountered: