Skip to content

Commit

Permalink
fix: explicit cast added to less for magnitudes to fix clang-arm64 …
Browse files Browse the repository at this point in the history
…conversion error
  • Loading branch information
mpusz committed Oct 3, 2024
1 parent cc521ee commit a95b2c7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/include/mp-units/framework/magnitude.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ template<typename T>
// Magnitude product implementation.
[[nodiscard]] consteval bool less(MagnitudeSpec auto lhs, MagnitudeSpec auto rhs)
{
return get_base_value(lhs) < get_base_value(rhs);
// clang-arm64 raises "error: implicit conversion from 'long' to 'long double' may lose precision" so we need an explicit cast
using ct = std::common_type_t<decltype(get_base_value(lhs)), decltype(get_base_value(rhs))>;
return static_cast<ct>(get_base_value(lhs)) < static_cast<ct>(get_base_value(rhs));
}

// The largest integer which can be extracted from any magnitude with only a single basis vector.
Expand Down

0 comments on commit a95b2c7

Please sign in to comment.