From: Matthias Maier Date: Mon, 7 Sep 2015 04:37:27 +0000 (-0500) Subject: Workaround for a bug in gcc-4.8 wrt to operator* and mixed std::complex types X-Git-Tag: v8.4.0-rc2~466^2~8 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d05a3c856738bc448434562d174bd0514390939;p=dealii.git Workaround for a bug in gcc-4.8 wrt to operator* and mixed std::complex types --- diff --git a/cmake/checks/check_03_compiler_bugs.cmake b/cmake/checks/check_03_compiler_bugs.cmake index 17c7a0db52..a1d8d1cd34 100644 --- a/cmake/checks/check_03_compiler_bugs.cmake +++ b/cmake/checks/check_03_compiler_bugs.cmake @@ -422,3 +422,19 @@ IF(DEAL_II_WITH_CXX11) ) RESET_CMAKE_REQUIRED() ENDIF() + + +# +# GCC 4.8 (and possibly older) have a regression that prevents our "trick" +# to allow multiplication of Tensor objects with std::complex and +# scalars U with different types T and U from working. In this case a +# specialization is needed. See also base/product_type_02.cc and +# base/product_type_03.cc +# +# - Matthias Maier, 2015 +# + +IF( CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND + CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9" ) + SET(DEAL_II_GCC_COMPLEX_CONV_BUG TRUE) +ENDIF() diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 72863f63b2..cf7f55f467 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -70,6 +70,7 @@ #cmakedefine DEAL_II_BIND_NO_CONST_OP_PARENTHESES #cmakedefine DEAL_II_CONSTEXPR_BUG #cmakedefine DEAL_II_ICC_SFINAE_BUG +#cmakedefine DEAL_II_GCC_COMPLEX_CONV_BUG /*********************************************************************** diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index a1e3d6eafe..28100f3110 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -1363,6 +1363,22 @@ operator * (const Tensor &t, } +#ifdef DEAL_II_GCC_COMPLEX_CONV_BUG +template +inline +Tensor<1,dim,typename ProductType::type>::type> +operator * (const Tensor<1,dim,Number> &t, + const OtherNumber factor) +{ + typedef typename ProductType::type product_type; + Tensor<1,dim,product_type> tt; + for (unsigned int d=0; d