It appears that most versions of the IBM XL compiler (including the latest
releases on Linux and OS X) don't handle const_cast<> of 2-dimensional arrays properly. If we're using one of the compilers that isn't friendly to such casts, fall back to a standard C-style cast. refs: #271 This commit was SVN r11263.
Этот коммит содержится в:
родитель
943e7dcfba
Коммит
1daa21e1e3
@ -183,6 +183,28 @@ AC_DEFUN([OMPI_SETUP_CXX],[
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# see if the compiler supports const_cast of 2-dimensional arrays
|
||||||
|
AC_LANG_PUSH(C++)
|
||||||
|
AC_CACHE_CHECK([if $CXX supports const_cast<> properly],
|
||||||
|
[ompi_cv_cxx_supports_2d_const_cast],
|
||||||
|
[AC_TRY_COMPILE([int non_const_func(int ranges[][3]);
|
||||||
|
int cast_test(const int ranges[][3]) {
|
||||||
|
return non_const_func(const_cast<int(*)[3]>(ranges));
|
||||||
|
}],
|
||||||
|
[],
|
||||||
|
[ompi_cv_cxx_supports_2d_const_cast="yes"],
|
||||||
|
[ompi_cv_cxx_supports_2d_const_cast="no"])])
|
||||||
|
if test "$ompi_cv_cxx_supports_2d_const_cast" = "yes" ; then
|
||||||
|
use_2d_const_cast=1
|
||||||
|
else
|
||||||
|
use_2d_const_cast=0
|
||||||
|
fi
|
||||||
|
AC_DEFINE_UNQUOTED([OMPI_CXX_SUPPORTS_2D_CONST_CAST],
|
||||||
|
[$use_2d_const_cast],
|
||||||
|
[Whether a const_cast on a 2-d array will work with the C++ compiler])
|
||||||
|
unset use_2d_const_cast
|
||||||
|
AC_LANG_POP(C++)
|
||||||
|
|
||||||
# Note: gcc-imperonating compilers accept -O3
|
# Note: gcc-imperonating compilers accept -O3
|
||||||
if test "$WANT_DEBUG" = "1"; then
|
if test "$WANT_DEBUG" = "1"; then
|
||||||
OPTFLAGS=
|
OPTFLAGS=
|
||||||
|
@ -74,6 +74,9 @@
|
|||||||
/* Whether we want MPI cxx support or not */
|
/* Whether we want MPI cxx support or not */
|
||||||
#undef OMPI_WANT_CXX_BINDINGS
|
#undef OMPI_WANT_CXX_BINDINGS
|
||||||
|
|
||||||
|
/* Whether a const_cast on a 2-d array will work with the C++ compiler */
|
||||||
|
#undef OMPI_CXX_SUPPORTS_2D_CONST_CAST
|
||||||
|
|
||||||
/* Whether we want the MPI f77 bindings or not */
|
/* Whether we want the MPI f77 bindings or not */
|
||||||
#undef OMPI_WANT_F77_BINDINGS
|
#undef OMPI_WANT_F77_BINDINGS
|
||||||
|
|
||||||
|
@ -97,7 +97,13 @@ inline MPI::Group
|
|||||||
MPI::Group::Range_incl(int n, const int ranges[][3]) const
|
MPI::Group::Range_incl(int n, const int ranges[][3]) const
|
||||||
{
|
{
|
||||||
MPI_Group newgroup;
|
MPI_Group newgroup;
|
||||||
(void)MPI_Group_range_incl(mpi_group, n, const_cast<int(*)[3]>(ranges), &newgroup);
|
(void)MPI_Group_range_incl(mpi_group, n,
|
||||||
|
#if OMPI_CXX_SUPPORTS_2D_CONST_CAST
|
||||||
|
const_cast<int(*)[3]>(ranges),
|
||||||
|
#else
|
||||||
|
(int(*)[3]) ranges,
|
||||||
|
#endif
|
||||||
|
&newgroup);
|
||||||
return newgroup;
|
return newgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +111,13 @@ inline MPI::Group
|
|||||||
MPI::Group::Range_excl(int n, const int ranges[][3]) const
|
MPI::Group::Range_excl(int n, const int ranges[][3]) const
|
||||||
{
|
{
|
||||||
MPI_Group newgroup;
|
MPI_Group newgroup;
|
||||||
(void)MPI_Group_range_excl(mpi_group, n, const_cast<int(*)[3]>(ranges), &newgroup);
|
(void)MPI_Group_range_excl(mpi_group, n,
|
||||||
|
#if OMPI_CXX_SUPPORTS_2D_CONST_CAST
|
||||||
|
const_cast<int(*)[3]>(ranges),
|
||||||
|
#else
|
||||||
|
(int(*)[3]) ranges,
|
||||||
|
#endif
|
||||||
|
&newgroup);
|
||||||
return newgroup;
|
return newgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user