diff --git a/cast.hpp b/cast.hpp index 86ead4c2..d46c4535 100644 --- a/cast.hpp +++ b/cast.hpp @@ -116,9 +116,16 @@ namespace cruft::cast { // is lossless. CHECK_EQ (static_cast (dst), src); return dst; - #else - return static_cast (src); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshorten-64-to-32" + if constexpr (std::is_enum_v) { + auto const val = static_cast> (src); + return static_cast (val); + } else { + return static_cast (src); + } +#pragma GCC diagnostic pop #endif }