From 381f8f3139533739c4a428843e2495b442989fcc Mon Sep 17 00:00:00 2001 From: Eugene Zhulenev Date: Thu, 12 Dec 2019 01:31:30 +0000 Subject: Initialize non-trivially constructible types when allocating a temp buffer. --- unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h b/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h index 701eb7128..f490bedd8 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h @@ -126,6 +126,12 @@ struct TensorEvaluator, Device> EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType) { const Index numValues = internal::array_prod(m_impl.dimensions()); m_buffer = m_device.get((CoeffReturnType*)m_device.allocate_temp(numValues * sizeof(CoeffReturnType))); + + // Initialize non-trivially constructible types. + if (!internal::is_arithmetic::value) { + for (Index i = 0; i < numValues; ++i) new (m_buffer + i) CoeffReturnType(); + } + typedef TensorEvalToOp< const typename internal::remove_const::type > EvalTo; EvalTo evalToTmp(m_device.get(m_buffer), m_op); -- cgit v1.2.3