From 0392b151879a5e143b74c603722a9cbdbb074c5b Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 8 Mar 2004 16:34:47 +0000 Subject: [PATCH] One more check for compiler bugs. git-svn-id: https://svn.dealii.org/trunk@8677 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/aclocal.m4 | 43 ++++++++++++++++ deal.II/base/include/base/config.h.in | 6 +-- deal.II/configure | 70 +++++++++++++++++++++++++++ deal.II/configure.in | 3 +- 4 files changed, 118 insertions(+), 4 deletions(-) diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index 0bc788bba3..00fc128e4d 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -2484,6 +2484,49 @@ AC_DEFUN(DEAL_II_CHECK_MEMBER_VAR_SPECIALIZATION_BUG, dnl +dnl ------------------------------------------------------------- +dnl gcc 2.95 doesn't like it if we have a member template function +dnl and define it as a template while specializing the outer class +dnl template. This is a nasty bug that is hard to work around... +dnl +dnl Usage: DEAL_II_CHECK_MEMBER_TEMPLATE_SPECIALIZATION_BUG +dnl +dnl ------------------------------------------------------------- +AC_DEFUN(DEAL_II_CHECK_MEMBER_TEMPLATE_SPECIALIZATION_BUG, dnl +[ + AC_MSG_CHECKING(for template member function specialization bug) + AC_LANG(C++) + CXXFLAGS="$CXXFLAGSG" + AC_TRY_COMPILE( + [ + template struct X + { + template void f(T); + }; + + template <> + template + void X<1>::f (T) + {} + + template void X<1>::f(int); + ], + [], + [ + AC_MSG_RESULT(no) + ], + [ + AC_MSG_RESULT(yes. using workaround) + AC_DEFINE(DEAL_II_MEMBER_VAR_SPECIALIZATION_BUG, 1, + [Defined if the compiler refuses to specialize + an outer class template while keeping a member + as a template. For the exact failure mode, look at + aclocal.m4 in the top-level directory.]) + ]) +]) + + + dnl ------------------------------------------------------------- dnl gcc3.1 (and maybe later compilers) has a bug with long double dnl and optimization (see code below), when compiling on Sparc diff --git a/deal.II/base/include/base/config.h.in b/deal.II/base/include/base/config.h.in index a06e7f34e2..8660e1db9e 100644 --- a/deal.II/base/include/base/config.h.in +++ b/deal.II/base/include/base/config.h.in @@ -85,9 +85,9 @@ directory for a description of this bug. */ #undef DEAL_II_MEMBER_OP_TEMPLATE_INST -/* Defined if the compiler refuses to allow the explicit specialization of - static member variables. For the exact failure mode, look at aclocal.m4 in - the top-level directory. */ +/* Defined if the compiler refuses to specialize an outer class template while + keeping a member as a template. For the exact failure mode, look at + aclocal.m4 in the top-level directory. */ #undef DEAL_II_MEMBER_VAR_SPECIALIZATION_BUG /* Minor version number of deal.II */ diff --git a/deal.II/configure b/deal.II/configure index d4bcb278cf..59b601f875 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -4966,6 +4966,76 @@ cat >>confdefs.h <<\_ACEOF _ACEOF +fi +rm -f conftest.$ac_objext conftest.$ac_ext + + + echo "$as_me:$LINENO: checking for template member function specialization bug" >&5 +echo $ECHO_N "checking for template member function specialization 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 X + { + template void f(T); + }; + + template <> + template + void X<1>::f (T) + {} + + template void X<1>::f(int); + +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_MEMBER_VAR_SPECIALIZATION_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 8cdcc1f6a6..3ae1b2bb3b 100644 --- a/deal.II/configure.in +++ b/deal.II/configure.in @@ -9,7 +9,7 @@ dnl is stored. dnl dnl dnl authors: Wolfgang Bangerth, Guido Kanschat, and others -dnl 1999, 2000, 2001, 2002 +dnl 1999, 2000, 2001, 2002, 2003, 2004 dnl @@ -176,6 +176,7 @@ DEAL_II_CHECK_FUNPTR_TEMPLATE_TEMPLATE_BUG DEAL_II_CHECK_NESTED_CLASS_FRIEND_BUG DEAL_II_CHECK_NESTED_CLASS_TEMPL_FRIEND_BUG DEAL_II_CHECK_MEMBER_VAR_SPECIALIZATION_BUG +DEAL_II_CHECK_MEMBER_TEMPLATE_SPECIALIZATION_BUG DEAL_II_CHECK_LONG_DOUBLE_LOOP_BUG DEAL_II_CHECK_ANON_NAMESPACE_BUG DEAL_II_CHECK_ANON_NAMESPACE_BUG2 -- 2.39.5