diff options
author | Eugene Zhulenev <eugene.zhulenev@gmail.com> | 2019-12-12 01:31:30 +0000 |
---|---|---|
committer | Eugene Zhulenev <eugene.zhulenev@gmail.com> | 2019-12-12 01:31:30 +0000 |
commit | 381f8f3139533739c4a428843e2495b442989fcc (patch) | |
tree | 53503557bc5048dbf97412bf58c26d00f34b22a4 /unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h | |
parent | 64272c7f40cf7450fe2f1b64fec37a0c97a59ba9 (diff) |
Initialize non-trivially constructible types when allocating a temp buffer.
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h | 6 |
1 files changed, 6 insertions, 0 deletions
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<const TensorForcedEvalOp<ArgType_>, 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<CoeffReturnType>::value) { + for (Index i = 0; i < numValues; ++i) new (m_buffer + i) CoeffReturnType(); + } + typedef TensorEvalToOp< const typename internal::remove_const<ArgType>::type > EvalTo; EvalTo evalToTmp(m_device.get(m_buffer), m_op); |