From: Jean-Paul Pelteret Date: Tue, 27 Dec 2022 21:42:59 +0000 (+0100) Subject: Fix ADOL-C tests broken by presence of static variables. X-Git-Tag: v9.5.0-rc1~703^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87c1195877301881931c2104a50ae0c0a0f1c494;p=dealii.git Fix ADOL-C tests broken by presence of static variables. --- 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