diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index bde25375d..b45946044 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -375,8 +375,23 @@ struct gemv_static_vector_if template struct gemv_static_vector_if { + #if EIGEN_ALIGN_STATICALLY internal::plain_array m_data; EIGEN_STRONG_INLINE Scalar* data() { return m_data.array; } + #else + // Some architectures cannot align on the stack, + // => let's manually enforce alignment by allocating more data and return the address of the first aligned element. + enum { + ForceAlignment = internal::packet_traits::Vectorizable, + PacketSize = internal::packet_traits::size + }; + internal::plain_array m_data; + EIGEN_STRONG_INLINE Scalar* data() { + return ForceAlignment + ? reinterpret_cast((reinterpret_cast(m_data.array) & ~(size_t(15))) + 16) + : m_data.array; + } + #endif }; template<> struct gemv_selector