[Mpi-forum] C++ issues

Jeff Squyres jsquyres at cisco.com
Fri Jun 29 07:27:13 CDT 2012

On Jun 29, 2012, at 8:17 AM, N.M. Maclaren wrote:

> I don't think that I did, but it is a real issue.  It is undefined behaviour
> of the worst kind to throw a C++ exception where there is a Fortran
> procedure in the call chain between the throw and the catch, and undefined
> behaviour of a seriously nasty kind when there is a C one.  

So are you saying that even MPI::ERRORS_THROW_EXCEPTIONS was a bad idea?  (Given that most [all?] MPI implementations are written in C)

> This has two consequences:
>   1) You can't replace MPI_ERRORS_THROW_EXCEPTIONS by a user-written
> hander, and
>   2) You can't define MPI_ERRORS_THROW_EXCEPTIONS in even vaguely
> standard C or Fortran using user-written handlers.
> Sorry, but that should be terminated with maximum prejudice.  It always
> was well-defined only for pure C++ code.
> [ The reason that it applies to C intermediates as well is that the C
> code may break the data structures used for the C++ stack unwinding.
> Most CURRENT compilers won't, but I have used ones that did, and it
> may well happen if you mix C and C++ compilers from different vendors,
> even today. ]

If we keep some form of MPI*ERRORS_THROW_EXCEPTIONS, perhaps we should add some possibility of it not being usable (e.g., for configurations where you can't safely throw a C++ exception through intermediate C code), like making MPI_ERRORS_THROW_EXCEPTIONS == MPI_ERRHANDLER_NULL, or some such...?

Jeff Squyres
jsquyres at cisco.com
For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/

More information about the mpi-forum mailing list