diff --git a/Eigen/src/Core/Fill.h b/Eigen/src/Core/Fill.h index 9d4ecd445..f40d56db6 100644 --- a/Eigen/src/Core/Fill.h +++ b/Eigen/src/Core/Fill.h @@ -78,8 +78,9 @@ template struct eigen_fill_impl { using Scalar = typename Xpr::Scalar; static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Xpr& dst, const Scalar& val) { + const Scalar val_copy = val; using std::fill_n; - fill_n(dst.data(), dst.size(), val); + fill_n(dst.data(), dst.size(), val_copy); } template static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Xpr& dst, const SrcXpr& src) {