From 87c1195877301881931c2104a50ae0c0a0f1c494 Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Tue, 27 Dec 2022 22:42:59 +0100 Subject: [PATCH] Fix ADOL-C tests broken by presence of static variables. --- include/deal.II/base/symmetric_tensor.h | 55 +++++++++++-------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index e9d01c5cde..a544deeb9b 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -1947,21 +1947,6 @@ DEAL_II_CONSTEXPR inline typename internal::SymmetricTensorAccessors:: // into a separate namespace namespace internal { - // The variables within this struct will be referenced in the next functions. - // It is a workaround that allows returning a reference to a static variable - // while allowing constexpr evaluation of the function. - // It has to be defined outside the function because constexpr functions - // cannot define static variables. - // A similar struct has also been defined in tensor.h - template - struct Uninitialized - { - static Type value; - }; - - template - Type Uninitialized::value; - template constexpr inline DEAL_II_ALWAYS_INLINE Number & symmetric_tensor_access(const TableIndices<2> &indices, @@ -2000,10 +1985,12 @@ namespace internal } } - // The code should never reach there. - // Returns a dummy reference to a dummy variable just to make the - // compiler happy. - return Uninitialized::value; + // The code should never reach here. + // We cannot return a static variable, as this class must support number + // types that require no instances of the number type to be in scope during + // a reinitialization procedure (e.g. ADOL-C adtl::adouble). + Assert(false, ExcInternalError()); + return data[0]; } @@ -2046,10 +2033,12 @@ namespace internal } } - // The code should never reach there. - // Returns a dummy reference to a dummy variable just to make the - // compiler happy. - return Uninitialized::value; + // The code should never reach here. + // We cannot return a static variable, as this class must support number + // types that require no instances of the number type to be in scope during + // a reinitialization procedure (e.g. ADOL-C adtl::adouble). + Assert(false, ExcInternalError()); + return data[0]; } @@ -2094,10 +2083,12 @@ namespace internal Assert(false, ExcNotImplemented()); } - // The code should never reach there. - // Returns a dummy reference to a dummy variable just to make the - // compiler happy. - return Uninitialized::value; + // The code should never reach here. + // We cannot return a static variable, as this class must support number + // types that require no instances of the number type to be in scope during + // a reinitialization procedure (e.g. ADOL-C adtl::adouble). + Assert(false, ExcInternalError()); + return data[0][0]; } @@ -2141,10 +2132,12 @@ namespace internal Assert(false, ExcNotImplemented()); } - // The code should never reach there. - // Returns a dummy reference to a dummy variable just to make the - // compiler happy. - return Uninitialized::value; + // The code should never reach here. + // We cannot return a static variable, as this class must support number + // types that require no instances of the number type to be in scope during + // a reinitialization procedure (e.g. ADOL-C adtl::adouble). + Assert(false, ExcInternalError()); + return data[0][0]; } } // end of namespace internal -- 2.39.5