]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test for yet another compiler bug.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 5 Feb 2004 22:39:57 +0000 (22:39 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 5 Feb 2004 22:39:57 +0000 (22:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@8401 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/aclocal.m4
deal.II/base/include/base/config.h.in
deal.II/configure
deal.II/configure.in
tests/tests.h

index d247ffef7ca58baee1eae3272b26785125a952af..a17ac6a94115f7da19cad28b790fcaa03aeea56b 100644 (file)
@@ -2714,6 +2714,66 @@ AC_DEFUN(DEAL_II_CHECK_ARRAY_CONDITIONAL_DECAY_BUG, dnl
 
 
 
+dnl -------------------------------------------------------------
+dnl Some versions of gcc get this example wrong:
+dnl ---------------------------------
+dnl struct X
+dnl {
+dnl     template <typename T> void operator << (T);
+dnl };
+dnl 
+dnl void f()
+dnl {
+dnl   X x;
+dnl   x.operator << <double> (1);
+dnl }
+dnl ---------------------------------
+dnl They want to see a "template" for disambiguation in
+dnl    x.template operator << <double> (1);
+dnl which shouldn't be necessary since the left hand side of the
+dnl dot operator is not template dependent. Surprisingly, this is
+dnl only the case for operators, not if operator<< were a regular
+dnl function. Annoyingly, other compilers barf on seeing the
+dnl disambiguating "template" keyword.
+dnl
+dnl Usage: DEAL_II_CHECK_TEMPL_OP_DISAMBIGUATION_BUG
+dnl
+dnl -------------------------------------------------------------
+AC_DEFUN(DEAL_II_CHECK_TEMPL_OP_DISAMBIGUATION_BUG, dnl
+[
+  AC_MSG_CHECKING(for template operator disambiguation bug)
+  AC_LANG(C++)
+  CXXFLAGS="$CXXFLAGSG"
+  AC_TRY_COMPILE(
+    [
+      struct X
+      {
+          template <typename T> void operator << (T);
+      };
+      
+      void f()
+      {
+        X x;
+        x.operator << <double> (1);
+      }
+    ],
+    [],
+    [
+      AC_MSG_RESULT(no)
+    ],
+    [
+      AC_MSG_RESULT(yes. using workaround)
+      AC_DEFINE(DEAL_II_TEMPL_OP_DISAMBIGUATION_BUG, 1, 
+                     [Defined if the compiler requires the use of the
+                      template keyword for disambiguation keyword in
+                      certain contexts in which it is not supposed to
+                      do so. For the exact failure mode, look at
+                      aclocal.m4 in the top-level directory.])
+    ])
+])
+
+
+
 dnl -------------------------------------------------------------
 dnl The boost::shared_ptr class has a templated assignment operator
 dnl but no assignment operator matching the default operator
index d97bb2eb5fd0db52d47a738b3c2263240d9c2b47..68e158834374f89333567379afa3c3ce68c3bf52 100644 (file)
    the top-level directory. */
 #undef DEAL_II_TEMPLATE_TEMPLATE_TYPEDEF_BUG
 
+/* Defined if the compiler requires the use of the template keyword for
+   disambiguation keyword in certain contexts in which it is not supposed to
+   do so. For the exact failure mode, look at aclocal.m4 in the top-level
+   directory. */
+#undef DEAL_II_TEMPL_OP_DISAMBIGUATION_BUG
+
 /* Define if we have to work around a bug with some compilers that will not
    allow us to specify a fully specialized class of a template as a friend.
    See the aclocal.m4 file in the top-level directory for a description of
index c41530236329310e3c88226640ffa878a575f88f..3953dc50198516159565b99cc8ba1a2332bc8927 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.159 .
+# From configure.in Revision: 1.160 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.57.
 #
@@ -5131,6 +5131,75 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+
+  echo "$as_me:$LINENO: checking for template operator disambiguation bug" >&5
+echo $ECHO_N "checking for template operator disambiguation bug... $ECHO_C" >&6
+  ac_ext=cc
+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
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+      struct X
+      {
+          template <typename T> void operator << (T);
+      };
+
+      void f()
+      {
+        X x;
+        x.operator << <double> (1);
+      }
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+      echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+      echo "$as_me:$LINENO: result: yes. using workaround" >&5
+echo "${ECHO_T}yes. using workaround" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define DEAL_II_TEMPL_OP_DISAMBIGUATION_BUG 1
+_ACEOF
+
+
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 
index d8e5b74be0fe3eb451d5d54ee6ec94b96dc31036..011720abd814dd7cd49f1613c914a92a7b75e1ab 100644 (file)
@@ -180,6 +180,7 @@ DEAL_II_CHECK_LONG_DOUBLE_LOOP_BUG
 DEAL_II_CHECK_ANON_NAMESPACE_BUG
 DEAL_II_CHECK_ANON_NAMESPACE_BUG2
 DEAL_II_CHECK_SFINAE_BUG
+DEAL_II_CHECK_TEMPL_OP_DISAMBIGUATION_BUG
 DEAL_II_CHECK_ARRAY_CONDITIONAL_DECAY_BUG
 DEAL_II_CHECK_BOOST_SHARED_PTR_ASSIGNMENT
 DEAL_II_HAVE_PRETTY_FUNCTION
index 512091a46160a947c350421a575b0ef3acb6e2b7..e58998636a2dbe410d9cbe2686412c12c804faaa 100644 (file)
@@ -16,7 +16,7 @@
 
 // common definitions used in all the tests
 
-
+#include <base/config.h>
 #include <base/logstream.h>
 #include <cmath>
 
@@ -29,9 +29,17 @@ LogStream & operator << (LogStream &logstream,
                          const double d)
 {
   if (std::fabs (d) < 1e-10)
-    logstream.operator << <double> (0.);
+    logstream.
+#ifdef DEAL_II_TEMPL_OP_DISAMBIGUATION_BUG
+      template
+#endif
+      operator << <double> (0.);
   else
-    logstream.operator << <double> (d);
+    logstream.
+#ifdef DEAL_II_TEMPL_OP_DISAMBIGUATION_BUG
+      template
+#endif
+      operator << <double> (d);
   return logstream;
 }
 
@@ -41,9 +49,17 @@ LogStream & operator << (LogStream &logstream,
                          const float d)
 {
   if (std::fabs (d) < 1e-8)
-    logstream.operator << <float> (0.);
+    logstream.
+#ifdef DEAL_II_TEMPL_OP_DISAMBIGUATION_BUG
+      template
+#endif
+      operator << <float> (0.);
   else
-    logstream.operator << <float> (d);
+    logstream.
+#ifdef DEAL_II_TEMPL_OP_DISAMBIGUATION_BUG
+      template
+#endif
+      operator << <float> (d);
   return logstream;
 }
 

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.