diff --git a/cql3/functions/castas_fcts.cc b/cql3/functions/castas_fcts.cc index eddfd44ddabe..74e824b47ed4 100644 --- a/cql3/functions/castas_fcts.cc +++ b/cql3/functions/castas_fcts.cc @@ -69,6 +69,16 @@ using bytes_opt = std::optional; template static data_value castas_fctn_simple(data_value from) { auto val_from = value_cast(from); + // Workaround for https://github.com/boostorg/multiprecision/issues/553 (the additional bug discovered post-closing) + if constexpr (std::is_floating_point_v && std::is_same_v) { + static auto min = utils::multiprecision_int(std::numeric_limits::lowest()); + static auto max = utils::multiprecision_int(std::numeric_limits::max()); + if (val_from < min) { + return -std::numeric_limits::infinity(); + } else if (val_from > max) { + return std::numeric_limits::infinity(); + } + } return static_cast(val_from); }