From e6a0069e95cbd8f62b40bf79f02a77d161d5d458 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 29 Jan 2007 18:44:46 +0000 Subject: [PATCH] Fix from an as-yet uncommitted test that Pak will commit shortly. Found another places that we were incorrectly casting a C++ MPI handle array to the corresponding C array type and hoping for the best (which won't work at all). This commit fixes things so that we now do the proper conversion between C<-->C++ handles. This commit was SVN r13346. --- ompi/mpi/cxx/datatype_inln.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ompi/mpi/cxx/datatype_inln.h b/ompi/mpi/cxx/datatype_inln.h index 4d4d2f264c..40c4670881 100644 --- a/ompi/mpi/cxx/datatype_inln.h +++ b/ompi/mpi/cxx/datatype_inln.h @@ -217,15 +217,22 @@ MPI::Datatype::Get_attr(int type_keyval, inline void MPI::Datatype::Get_contents(int max_integers, int max_addresses, - int max_datatypes, int array_of_integers[], - MPI::Aint array_of_addresses[], - MPI::Datatype array_of_datatypes[]) - const + int max_datatypes, int array_of_integers[], + MPI::Aint array_of_addresses[], + MPI::Datatype array_of_datatypes[]) const { - (void) MPI_Type_get_contents(mpi_datatype, max_integers, max_addresses, - max_datatypes, const_cast(array_of_integers), - const_cast(array_of_addresses), - (MPI_Datatype *)(array_of_datatypes)); + int i; + MPI_Datatype *d = new MPI_Datatype[max_datatypes]; + + (void) MPI_Type_get_contents(mpi_datatype, max_integers, max_addresses, + max_datatypes, + const_cast(array_of_integers), + const_cast(array_of_addresses), d); + // Convert the C MPI_Datatypes to the user's OUT MPI::Datatype + // array parameter + for (i = 0; i < max_datatypes; ++i) { + array_of_datatypes[i] = d[i]; + } } inline void