]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Work around a problem where gcc and icc require mutually incompatible workarounds...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 22 Apr 2010 15:26:08 +0000 (15:26 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 22 Apr 2010 15:26:08 +0000 (15:26 +0000)
git-svn-id: https://svn.dealii.org/trunk@21025 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/aclocal.m4
deal.II/base/include/base/config.h.in
deal.II/configure
deal.II/configure.in
deal.II/deal.II/source/fe/fe_values.cc

index 488d54d199f9ec65640a7226ff883099b68d6b52..773b5493a96a7356adc7164d087c3ac7b580a0d7 100644 (file)
@@ -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 <int dim, int spacedim> struct Scalar {};
+        }
+
+        template <int dim, int spacedim>
+        struct X
+        {
+            FEValuesViews::Scalar<dim,spacedim> scalars[dim*spacedim];
+
+            void f()
+              {
+                scalars[0].dealii::FEValuesViews::Scalar<dim,spacedim>::~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:
index 5ca281405868dc961975c1a786aa58d64ba1b9d7..0fb95fd907cad2ad95896f9b190fb601db16af93 100644 (file)
    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. */
index 75c96ab9cbfc2b5ec53718ed3de3db6313c5948e..3f6359b58807c33b012d09ec6ff12a9d734e475b 100755 (executable)
@@ -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 <int dim, int spacedim> struct Scalar {};
+        }
+
+        template <int dim, int spacedim>
+        struct X
+        {
+            FEValuesViews::Scalar<dim,spacedim> scalars[dim*spacedim];
+
+            void f()
+              {
+                scalars[0].dealii::FEValuesViews::Scalar<dim,spacedim>::~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
index 7ce8604fceb58f5d5fb42b912f6e4b2fda54d132..6b4b5b2623a28c69a952f071ef35b1c16cbaa30a 100644 (file)
@@ -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
index 4ba9e7bb3e3decbdc6d1b0a42ab0a75d1c89ad7f..c141fe27716537a907beed4d12ce8f4b42697b30 100644 (file)
@@ -1053,8 +1053,12 @@ namespace internal
       scalars.resize (n_scalars);
       for (unsigned int component=0; component<n_scalars; ++component)
        {
+#ifndef DEAL_II_EXPLICIT_DESTRUCTOR_BUG
+         scalars[component].dealii::FEValuesViews::Scalar<dim,spacedim>::~Scalar ();
+#else
          typedef dealii::FEValuesViews::Scalar<dim,spacedim> ScalarView;
-         scalars[component].ScalarView::~Scalar ();
+         scalars[component].ScalarView::~ScalarView ();
+#endif
          new (&scalars[component])
            dealii::FEValuesViews::Scalar<dim,spacedim>(fe_values,
                                                        component);
@@ -1073,8 +1077,12 @@ namespace internal
       vectors.resize (n_vectors);
       for (unsigned int component=0; component<n_vectors; ++component)
        {
+#ifndef DEAL_II_EXPLICIT_DESTRUCTOR_BUG
+         vectors[component].dealii::FEValuesViews::Vector<dim,spacedim>::~Vector ();
+#else
          typedef dealii::FEValuesViews::Vector<dim,spacedim> VectorView;
-         vectors[component].VectorView::~Vector ();
+         vectors[component].VectorView::~VectorView ();
+#endif
          new (&vectors[component])
            dealii::FEValuesViews::Vector<dim,spacedim>(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);

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.