diff --git a/cast.hpp b/cast.hpp index fe928c8d..ff4ba02d 100644 --- a/cast.hpp +++ b/cast.hpp @@ -107,6 +107,14 @@ namespace cruft::cast { lossless (const SrcT &src) { #ifndef NDEBUG + // GCC insists that the initial static_cast to DstT is a floating + // point comparison if we pass in a bool and a float. + // + // The only way around this is to ignore the warning locally (we use + // almost_equal inside CHECK_EQ anyway, so it should not be a concern). + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" + auto dst = static_cast (src); if constexpr (std::is_floating_point_v) { @@ -120,6 +128,8 @@ namespace cruft::cast { // Cast dst back to src to check round-trip conversion // is lossless. CHECK_EQ (static_cast (dst), src); + + #pragma GCC diagnostic pop return dst; #else #pragma GCC diagnostic push