From 8ffcf2d061dc34a66fad4fa45d4712a9af06349e Mon Sep 17 00:00:00 2001 From: wolf Date: Wed, 8 Jan 2003 15:23:48 +0000 Subject: [PATCH] The last (reduced) check-in works with gcc, but breaks icc, unfortunately. This is a minefield... git-svn-id: https://svn.dealii.org/trunk@6889 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/aclocal.m4 | 61 +++++++++++++ deal.II/base/include/base/config.h.in | 6 ++ deal.II/base/include/base/thread_management.h | 88 ++++++++++++++----- deal.II/configure | 73 ++++++++++++++- deal.II/configure.in | 1 + 5 files changed, 206 insertions(+), 23 deletions(-) diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index e1f50cd522..1d71d3387e 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -1965,6 +1965,67 @@ AC_DEFUN(DEAL_II_CHECK_TEMPL_CONST_MEM_PTR_BUG, dnl +dnl ------------------------------------------------------------- +dnl More Intel ICC 5.0.1 compiler lossage with pointers to constant +dnl member functions +dnl --------------------------------- +dnl template struct Y { +dnl typedef void (Class::*FunPtr) (); +dnl FunPtr fun_ptr; +dnl Class *object; +dnl void foo () { +dnl (object->*fun_ptr)(); +dnl }; +dnl }; +dnl +dnl struct X {}; +dnl +dnl template class Y; +dnl --------------------------------- +dnl Again, it does not store the information that the member function pointer +dnl refers to a constant object, so complains that the object is constant, +dnl but the member function is not. +dnl +dnl Usage: DEAL_II_CHECK_CONST_MEM_FUN_PTR_BUG +dnl +dnl ------------------------------------------------------------- +AC_DEFUN(DEAL_II_CHECK_CONST_MEM_FUN_PTR_BUG, dnl +[ + AC_MSG_CHECKING(for const member function pointers bug) + AC_LANG(C++) + CXXFLAGS="$CXXFLAGSG" + AC_TRY_COMPILE( + [ + template struct Y { + typedef void (Class::*FunPtr) (); + FunPtr fun_ptr; + Class *object; + void foo () { + (object->*fun_ptr)(); + }; + }; + + struct X {}; + + template class Y; + ], + [], + [ + AC_MSG_RESULT(no) + ], + [ + AC_MSG_RESULT(yes. using workaround) + AC_DEFINE(DEAL_II_CONST_MEM_FUN_PTR_BUG, 1, + [Define if we have to work around another bug in Intel's icc + compiler in which the compiler refuses to store the const + attribute at a member function pointer with a constant class. + See the aclocal.m4 file in the top-level directory + for a description of this bug.]) + ]) +]) + + + dnl ------------------------------------------------------------- dnl DEC/Compaq's cxx compiler does not want us to implement dnl virtual functions that were declared abstract before. We do diff --git a/deal.II/base/include/base/config.h.in b/deal.II/base/include/base/config.h.in index 742111ade4..a8ac42bce9 100644 --- a/deal.II/base/include/base/config.h.in +++ b/deal.II/base/include/base/config.h.in @@ -36,6 +36,12 @@ */ #undef DEAL_II_COMPAT_MAPPING +/* Define if we have to work around another bug in Intel's icc compiler in + which the compiler refuses to store the const attribute at a member + function pointer with a constant class. See the aclocal.m4 file in the + top-level directory for a description of this bug. */ +#undef DEAL_II_CONST_MEM_FUN_PTR_BUG + /* Flag indicating whether the library shall be compiled to use the Tecplot interface */ #undef DEAL_II_HAVE_TECPLOT diff --git a/deal.II/base/include/base/thread_management.h b/deal.II/base/include/base/thread_management.h index a5461d29b9..d091a39105 100644 --- a/deal.II/base/include/base/thread_management.h +++ b/deal.II/base/include/base/thread_management.h @@ -412,17 +412,21 @@ namespace Threads typedef RetType (Class::*type) (); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr0 { typedef RetType (Class::*type) () const; }; - +#endif /** * Given a class, argument types, * and the return type, generate a @@ -435,17 +439,21 @@ namespace Threads typedef RetType (Class::*type) (Arg1); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr1 { typedef RetType (Class::*type) (Arg1) const; }; - +#endif /** * Given a class, argument types, * and the return type, generate a @@ -458,17 +466,21 @@ namespace Threads typedef RetType (Class::*type) (Arg1, Arg2); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr2 { typedef RetType (Class::*type) (Arg1, Arg2) const; }; - +#endif /** * Given a class, argument types, @@ -482,17 +494,21 @@ namespace Threads typedef RetType (Class::*type) (Arg1, Arg2, Arg3); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr3 { typedef RetType (Class::*type) (Arg1, Arg2, Arg3) const; }; - +#endif /** * Given a class, argument types, @@ -506,17 +522,21 @@ namespace Threads typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr4 { typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4) const; }; - +#endif /** * Given a class, argument types, @@ -530,17 +550,21 @@ namespace Threads typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr5 { typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5) const; }; - +#endif /** * Given a class, argument types, @@ -554,17 +578,21 @@ namespace Threads typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr6 { typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) const; }; - +#endif /** * Given a class, argument types, @@ -578,17 +606,21 @@ namespace Threads typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr7 { typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) const; }; - +#endif /** @@ -603,17 +635,21 @@ namespace Threads typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr8 { typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8) const; }; - +#endif @@ -629,17 +665,21 @@ namespace Threads typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr9 { typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9) const; }; - +#endif @@ -656,17 +696,21 @@ namespace Threads typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10); }; +#ifdef DEAL_II_CONST_MEM_FUN_PTR_BUG /** * Same as above, but for the case * of a member function marked - * @p{const}. + * @p{const}. This should not + * really be necessary, but Intel's + * compiler has a bug here so we + * have to work around. */ template struct MemFunPtr10 { typedef RetType (Class::*type) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10) const; }; - +#endif diff --git a/deal.II/configure b/deal.II/configure index 5ac02669f5..37f4160dbd 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.134 . +# From configure.in Revision: 1.135 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57. # @@ -4419,6 +4419,77 @@ cat >>confdefs.h <<\_ACEOF _ACEOF +fi +rm -f conftest.$ac_objext conftest.$ac_ext + + + echo "$as_me:$LINENO: checking for const member function pointers bug" >&5 +echo $ECHO_N "checking for const member function pointers 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. */ + + template struct Y { + typedef void (Class::*FunPtr) (); + FunPtr fun_ptr; + Class *object; + void foo () { + (object->*fun_ptr)(); + }; + }; + + struct X {}; + + template class Y; + +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_CONST_MEM_FUN_PTR_BUG 1 +_ACEOF + + fi rm -f conftest.$ac_objext conftest.$ac_ext diff --git a/deal.II/configure.in b/deal.II/configure.in index c6631de14b..5a04708887 100644 --- a/deal.II/configure.in +++ b/deal.II/configure.in @@ -170,6 +170,7 @@ DEAL_II_CHECK_MEMBER_OP_TEMPLATE_INST DEAL_II_CHECK_NAMESP_TEMPL_FRIEND_BUG DEAL_II_CHECK_TEMPL_SPEC_FRIEND_BUG DEAL_II_CHECK_TEMPL_CONST_MEM_PTR_BUG +DEAL_II_CHECK_CONST_MEM_FUN_PTR_BUG DEAL_II_CHECK_IMPLEMENTED_PURE_FUNCTION_BUG DEAL_II_CHECK_TEMPLATE_TEMPLATE_TYPEDEF_BUG DEAL_II_CHECK_NESTED_CLASS_FRIEND_BUG -- 2.39.5