From: bangerth Date: Thu, 22 Apr 2010 15:26:08 +0000 (+0000) Subject: Work around a problem where gcc and icc require mutually incompatible workarounds... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d56abbb6836fbf4874bd6feee721e39f4c9c41b4;p=dealii-svn.git Work around a problem where gcc and icc require mutually incompatible workarounds for the same problem. git-svn-id: https://svn.dealii.org/trunk@21025 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index 488d54d199..773b5493a9 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -2815,6 +2815,59 @@ AC_DEFUN(DEAL_II_CHECK_MEMBER_OP_TEMPLATE_INST, dnl +dnl ------------------------------------------------------------- +dnl Some compiler versions, notably ICC, have trouble with the +dnl following code in which we explicitly call a destructor. +dnl This has to be worked around with a typedef. The problem is +dnl that the workaround fails with some other compilers, so that +dnl we can not unconditionally use the workaround... +dnl +dnl Usage: DEAL_II_CHECK_EXPLICIT_DESTRUCTOR_BUG +dnl +dnl ------------------------------------------------------------- +AC_DEFUN(DEAL_II_CHECK_EXPLICIT_DESTRUCTOR_BUG, dnl +[ + AC_MSG_CHECKING(for explicit destructor call bug) + AC_LANG(C++) + CXXFLAGS="$CXXFLAGSG" + AC_TRY_COMPILE( + [ + namespace dealii + { + namespace FEValuesViews + { + template struct Scalar {}; + } + + template + struct X + { + FEValuesViews::Scalar scalars[dim*spacedim]; + + void f() + { + scalars[0].dealii::FEValuesViews::Scalar::~Scalar (); + } + }; + + template struct X<2,2>; + } + ], + [], + [ + AC_MSG_RESULT(no) + ], + [ + AC_MSG_RESULT(yes. using workaround) + AC_DEFINE_UNQUOTED(DEAL_II_EXPLICIT_DESTRUCTOR_BUG, 1, + [Define if we have to work around a bug where the + compiler doesn't accept an explicit destructor call. + See the aclocal.m4 file in the top-level directory + for a description of this bug.]) + ]) +]) + + dnl ------------------------------------------------------------- dnl Versions of GCC before 3.0 had a problem with the following dnl code: diff --git a/deal.II/base/include/base/config.h.in b/deal.II/base/include/base/config.h.in index 5ca2814058..0fb95fd907 100644 --- a/deal.II/base/include/base/config.h.in +++ b/deal.II/base/include/base/config.h.in @@ -95,6 +95,11 @@ constructors. */ #undef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG +/* Define if we have to work around a bug where the compiler doesn't accept an + explicit destructor call. See the aclocal.m4 file in the top-level + directory for a description of this bug. */ +#undef DEAL_II_EXPLICIT_DESTRUCTOR_BUG + /* Defined if the compiler needs a workaround for certain problems with taking the address of template template functions. For the details, look at aclocal.m4 in the top-level directory. */ diff --git a/deal.II/configure b/deal.II/configure index 75c96ab9cb..3f6359b588 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -6524,6 +6524,91 @@ _ACEOF + { $as_echo "$as_me:$LINENO: checking for explicit destructor call bug" >&5 +$as_echo_n "checking for explicit destructor call bug... " >&6; } + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CXXFLAGS="$CXXFLAGSG" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + namespace dealii + { + namespace FEValuesViews + { + template struct Scalar {}; + } + + template + struct X + { + FEValuesViews::Scalar scalars[dim*spacedim]; + + void f() + { + scalars[0].dealii::FEValuesViews::Scalar::~Scalar (); + } + }; + + template struct X<2,2>; + } + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + { $as_echo "$as_me:$LINENO: result: yes. using workaround" >&5 +$as_echo "yes. using workaround" >&6; } + +cat >>confdefs.h <<_ACEOF +#define DEAL_II_EXPLICIT_DESTRUCTOR_BUG 1 +_ACEOF + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:$LINENO: checking for 1st template friend in namespace bug" >&5 $as_echo_n "checking for 1st template friend in namespace bug... " >&6; } ac_ext=cpp diff --git a/deal.II/configure.in b/deal.II/configure.in index 7ce8604fce..6b4b5b2623 100644 --- a/deal.II/configure.in +++ b/deal.II/configure.in @@ -164,6 +164,7 @@ DEAL_II_CHECK_ASSERT_THROW(optimized, $CXXFLAGSO, DEAL_II_CHECK_LOCAL_TYPEDEF_COMP DEAL_II_CHECK_TEMPLATE_SPEC_ACCESS DEAL_II_CHECK_MEMBER_OP_TEMPLATE_INST +DEAL_II_CHECK_EXPLICIT_DESTRUCTOR_BUG DEAL_II_CHECK_NAMESP_TEMPL_FRIEND_BUG DEAL_II_CHECK_NAMESP_TEMPL_FRIEND_BUG2 DEAL_II_CHECK_TEMPL_SPEC_FRIEND_BUG diff --git a/deal.II/deal.II/source/fe/fe_values.cc b/deal.II/deal.II/source/fe/fe_values.cc index 4ba9e7bb3e..c141fe2771 100644 --- a/deal.II/deal.II/source/fe/fe_values.cc +++ b/deal.II/deal.II/source/fe/fe_values.cc @@ -1053,8 +1053,12 @@ namespace internal scalars.resize (n_scalars); for (unsigned int component=0; component::~Scalar (); +#else typedef dealii::FEValuesViews::Scalar ScalarView; - scalars[component].ScalarView::~Scalar (); + scalars[component].ScalarView::~ScalarView (); +#endif new (&scalars[component]) dealii::FEValuesViews::Scalar(fe_values, component); @@ -1073,8 +1077,12 @@ namespace internal vectors.resize (n_vectors); for (unsigned int component=0; component::~Vector (); +#else typedef dealii::FEValuesViews::Vector VectorView; - vectors[component].VectorView::~Vector (); + vectors[component].VectorView::~VectorView (); +#endif new (&vectors[component]) dealii::FEValuesViews::Vector(fe_values, component); @@ -1089,8 +1097,13 @@ namespace internal symmetric_second_order_tensors.resize(n_symmetric_second_order_tensors); for (unsigned int component = 0; component < n_symmetric_second_order_tensors; ++component) { +#ifndef DEAL_II_EXPLICIT_DESTRUCTOR_BUG + symmetric_second_order_tensors[component] + .dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim>::~SymmetricTensor(); +#else typedef dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim> SymmetricTensorView; symmetric_second_order_tensors[component].SymmetricTensorView::~SymmetricTensor(); +#endif new (&symmetric_second_order_tensors[component]) dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim > (fe_values, component);