From acfa8a551a46f780ab69ffa2e67cbada71a08e35 Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Sat, 12 Aug 2017 01:05:43 -0600 Subject: [PATCH] Explicitly initialise tensor contraction results to zero. --- include/deal.II/base/tensor_accessors.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/deal.II/base/tensor_accessors.h b/include/deal.II/base/tensor_accessors.h index 52c7ca7bf1..2ca2674e47 100644 --- a/include/deal.II/base/tensor_accessors.h +++ b/include/deal.II/base/tensor_accessors.h @@ -665,7 +665,9 @@ namespace TensorAccessors inline DEAL_II_ALWAYS_INLINE static T1 contract2(const T2 &left, const T3 &right) { - T1 result = T1(); + // Some auto-differentiable numbers need explicit + // zero initialization. + T1 result = dealii::internal::NumberType::value(0.0); for (unsigned int i = 0; i < dim; ++i) result += Contract2::template contract2(left[i], right[i]); return result; @@ -710,7 +712,9 @@ namespace TensorAccessors static inline T1 contract3(const T2 &left, const T3 &middle, const T4 &right) { - T1 result = T1(); + // Some auto-differentiable numbers need explicit + // zero initialization. + T1 result = dealii::internal::NumberType::value(0.0); for (unsigned int i = 0; i < dim; ++i) result += Contract3::template contract3(left[i], middle[i], right); return result; @@ -736,7 +740,9 @@ namespace TensorAccessors static inline T1 contract3(const T2 &left, const T3 &middle, const T4 &right) { - T1 result = T1(); + // Some auto-differentiable numbers need explicit + // zero initialization. + T1 result = dealii::internal::NumberType::value(0.0); for (unsigned int i = 0; i < dim; ++i) result += Contract3<0, rank_2 - 1, dim>::template contract3(left, middle[i], right[i]); return result; -- 2.39.5