[mpich-discuss] MPI_C_BOOL and bool

Torquil Macdonald Sørensen torquil at gmail.com
Fri Apr 8 11:40:29 CDT 2011


Hi all!

In my MPICH2 program, sizeof(MPI_C_BOOL) returns 4.

On the other hand, sizeof(bool) returns 1.

Does that mean that the following might result in a segfault?:

bool buf = false;
MPI_Bcast(&buf, 1, MPI_C_BOOL, 0, MPI_COMM_WORLD);

After all, MPICH then writes a 4 byte amount of data to the buffer, for which 
only 1 byte is allocated. I'm using MPICH2 1.4rc1 at the moment.

I came over this message regarding the MPI2.2 standard:

http://www.unixer.de/blog/index.php/2009/07/30/the-mpi-standard-mpi-22-is-
fixed-now/

where it seems to be explained that MPI_C_BOOL is 4 bytes due to some kind of 
oversight, and that it will be changed in an errata to the MPI2.2 standard.

In conclusion, does all this mean that I cannot use 'bool' and MPI_C_BOOL 
together until sometime in the future?

Thanks!
Torquil Sørensen


More information about the mpich-discuss mailing list