You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I'm not mistaken, the bit tricks used to reinterpret the floating point numbers as integers are specific to the IEEE 754 representation of floating point numbers, which isn't guaranteed by the C++ standard. Instead of blindly accepting every standard floating point type, you should guard the sort at compile-time with std::numeric_limits<T>::is_iec559 so that it rejects non-IEEE 754 compliant floating points types.
Additionally, you're using type punning through an union between integral and floating point type, which is undefined behaviour. A standard compliant solution would be to use std::memcpy instead.
The text was updated successfully, but these errors were encountered:
I added a few compile-time checks to my ska-sorter branch in cpp-sort. You might want to have some of those checks as static_assert to avoid problems such as the ones described above for float and double on strange targets :)
If I'm not mistaken, the bit tricks used to reinterpret the floating point numbers as integers are specific to the IEEE 754 representation of floating point numbers, which isn't guaranteed by the C++ standard. Instead of blindly accepting every standard floating point type, you should guard the sort at compile-time with
std::numeric_limits<T>::is_iec559
so that it rejects non-IEEE 754 compliant floating points types.Additionally, you're using type punning through an union between integral and floating point type, which is undefined behaviour. A standard compliant solution would be to use
std::memcpy
instead.The text was updated successfully, but these errors were encountered: