]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Detect and work around a bug in an old version of gcc.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 22 Oct 2003 23:51:13 +0000 (23:51 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 22 Oct 2003 23:51:13 +0000 (23:51 +0000)
git-svn-id: https://svn.dealii.org/trunk@8137 0785d39b-7218-0410-832d-ea1e28bc413d

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

index c40b5a92ee7b4325c5d0a4d66513b18adf6242f4..4a2337b0dbdf2af553e76579b0ae94bbbe42ec94 100644 (file)
@@ -2629,6 +2629,40 @@ AC_DEFUN(DEAL_II_CHECK_SFINAE_BUG, dnl
 
 
 
+dnl -------------------------------------------------------------
+dnl Old versions of gcc had a problem with arrays inside ?: 
+dnl expressions: they decayed too quickly to pointers. This then
+dnl leads to erroneous warnings :-(
+dnl
+dnl Usage: DEAL_II_CHECK_ARRAY_CONDITIONAL_DECAY_BUG
+dnl
+dnl -------------------------------------------------------------
+AC_DEFUN(DEAL_II_CHECK_ARRAY_CONDITIONAL_DECAY_BUG, dnl
+[
+  AC_MSG_CHECKING(for array assignment in conditional bug)
+  AC_LANG(C++)
+  CXXFLAGS="-W -Wall -Werror"
+  AC_TRY_COMPILE(
+    [
+    ],
+    [
+  const int x[2][2] = {{1,1},{1,1}};
+  const int (&y)[2] = (1 ? x[0] : x[1]);
+  return y[0];
+    ],
+    [
+      AC_MSG_RESULT(no)
+    ],
+    [
+      AC_MSG_RESULT(yes)
+      AC_DEFINE(DEAL_II_ARRAY_CONDITIONAL_DECAY_BUG, 1, 
+                     [Defined if the compiler has a problem with
+                     assigning arrays in conditionals])
+    ])
+])
+
+
+
 dnl -------------------------------------------------------------
 dnl The boost::shared_ptr class has a templated assignment operator
 dnl but no assignment operator matching the default operator
index 86146093d1004be2b108e76a3b2844f4df908ba8..253ee80ccb3e841aa599d512f9ba695b81bd9405 100644 (file)
  * The constants defined here are a subset of the @p{M_XXX} constants sometimes
  * declared in the system include file @p{math.h}, but without the 
  * prefix @p{M_}.
+ *
+ * In addition to that, we declare @p{invalid_unsigned_int} to be the
+ * largest unsigned integer representable; this value is widely used in
+ * the library as a marker for an invalid index, an invalid size of an
+ * array, and similar purposes.
  */
 namespace deal_II_numbers {
+                                             /**
+                                              * Representation of the
+                                              * largest number that
+                                              * can be put into an
+                                              * unsigned integer. This
+                                              * value is widely used
+                                              * throughout the library
+                                              * as a marker for an
+                                              * invalid unsigned
+                                              * integer value, such as
+                                              * an invalid array
+                                              * index, an invalid
+                                              * array size, and the
+                                              * like.
+                                              */
+  static const unsigned int 
+    invalid_unsigned_int = static_cast<unsigned int> (-1);
+
                                              /**
                                               * e
                                               */
index 20fc6e872ad4cce8ef6966a6e1d43322592f2813..b6e66aae0362b84224db4fa1c641bbef62d1f61b 100755 (executable)
@@ -5102,6 +5102,69 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+
+  echo "$as_me:$LINENO: checking for array assignment in conditional bug" >&5
+echo $ECHO_N "checking for array assignment in conditional 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="-W -Wall -Werror"
+  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.  */
+
+
+int
+main ()
+{
+
+  const int x[2][2] = {{1,1},{1,1}};
+  const int (&y)[2] = (1 ? x[0] : x[1]);
+  return y[0];
+
+  ;
+  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" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define DEAL_II_ARRAY_CONDITIONAL_DECAY_BUG 1
+_ACEOF
+
+
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 
index 51402e25de39a5406b5fd72722b8668f336ef166..47f5de4ad2f6906db513922eba15ab69139b39d6 100644 (file)
@@ -179,6 +179,7 @@ DEAL_II_CHECK_MEMBER_VAR_SPECIALIZATION_BUG
 DEAL_II_CHECK_LONG_DOUBLE_LOOP_BUG
 DEAL_II_CHECK_ANON_NAMESPACE_BUG
 DEAL_II_CHECK_SFINAE_BUG
+DEAL_II_CHECK_ARRAY_CONDITIONAL_DECAY_BUG
 DEAL_II_CHECK_BOOST_SHARED_PTR_ASSIGNMENT
 DEAL_II_HAVE_PRETTY_FUNCTION
 DEAL_II_HAVE_STD_ITERATOR
@@ -436,8 +437,31 @@ AH_BOTTOM(
  * The constants defined here are a subset of the @p{M_XXX} constants sometimes
  * declared in the system include file @p{math.h}, but without the 
  * prefix @p{M_}.
+ *
+ * In addition to that, we declare @p{invalid_unsigned_int} to be the
+ * largest unsigned integer representable; this value is widely used in
+ * the library as a marker for an invalid index, an invalid size of an
+ * array, and similar purposes.
  */
 namespace deal_II_numbers {
+                                             /**
+                                              * Representation of the
+                                              * largest number that
+                                              * can be put into an
+                                              * unsigned integer. This
+                                              * value is widely used
+                                              * throughout the library
+                                              * as a marker for an
+                                              * invalid unsigned
+                                              * integer value, such as
+                                              * an invalid array
+                                              * index, an invalid
+                                              * array size, and the
+                                              * like.
+                                              */
+  static const unsigned int 
+    invalid_unsigned_int = static_cast<unsigned int> (-1);
+
                                              /**
                                               * e
                                               */

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.