From: Dave Goodell Date: November 27, 2007 4:40:38 PM CST To: mpi-21@XXXXXXXXXXXXX Cc: Dave Goodell Subject: Re: [mpi-21] MPI::BOTTOM Reply-To: mpi-21@XXXXXXXXXXXXX On Nov 27, 2007, at 3:27 PM, Jeff Squyres wrote: > A user recently raised an issue that I just looked into and > discovered a problem with the C++ binding for MPI::BOTTOM. > > In the spec, MPI::BOTTOM is defined to be of type (const void*). > However, all receive buffers are defined to be of type (void*) -- > such as for the various flavors of point-to-point receive, the > receive buffer for collectives, etc. This means that you'll get a > compiler error when trying to use MPI::BOTTOM as a receive buffer: > > bottom.cc:81: error: invalid conversion from Ôconst void*' to > Ôvoid*' > bottom.cc:81: error: initializing argument 1 of Ôvirtual void > MPI::Comm::Bcast(void*, int, const MPI::Datatype&, int) const' > > A user can cast away the const-ness of MPI::BOTTOM, but that seems > inelegant/wrong. > > I don't yet have a solution to this problem; I raise it here so > that it gets added to the list of issues to be addressed in MPI-2.1. Looks like the const is on the wrong side of the declaration. That is, unless my C++ is too rusty it should instead be something like: namespace MPI { ... extern void * const BOTTOM; ... } "const TYPE * FOO" indicates that the data pointed to by FOO is read- only. So "*FOO = BAR;" would be an illegal statement. "TYPE * const FOO" indicates that the memory holding the value of FOO is read-only. So "FOO = &BAR;" would be an illegal statement. The latter seems to be what is desired for MPI::BOTTOM: an address that cannot be changed but a the data that it references can. -- Dave Goodell Argonne National Laboratory