Fix integer sanitizer issues in shifts and test ranges

libeigen/eigen!2320

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-03-20 17:27:02 -07:00
parent 89621d1024
commit 8115b45e50
4 changed files with 33 additions and 6 deletions

View File

@@ -1923,7 +1923,8 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double fmod(const double& a, const double&
template <typename Scalar, typename Enable = std::enable_if_t<std::is_integral<Scalar>::value>>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar logical_shift_left(const Scalar& a, int n) {
return a << n;
using UnsignedScalar = typename numext::get_integer_by_size<sizeof(Scalar)>::unsigned_type;
return bit_cast<Scalar, UnsignedScalar>(bit_cast<UnsignedScalar, Scalar>(a) << n);
}
template <typename Scalar, typename Enable = std::enable_if_t<std::is_integral<Scalar>::value>>