_mp_alloc vs ALLOC

Niels Möller nisse at lysator.liu.se
Tue Jun 5 07:38:32 CEST 2012

Marc Glisse <marc.glisse at inria.fr> writes:

> On Mon, 4 Jun 2012, Niels Möller wrote:
>> (but I'm not sure I'd trust the automatic stack unwinding with C++
>> exceptions either...).
> Why not?

*Maybe* I'd trust it if I knew better how it works. I don't have much
experience in C++.

My understanding is that it's very hairy to get right. You have to take
into account that the stack may contain a mix of frames from C++ and C
functions (in particular if you have callback functions), and I think
I've even heard horror stories about the stack unwinding code having to
interpret the machine instructions around the return addresses in
certain cases.

And then on top of that, the general problem of adding exceptions to
existing code late in the game; if you have a large program using a mix
of C and C++ libraries calling each other, it's likely that at least
some piece of all that code is not prepared for sudden stack unwinding.

I'd have more confidence in using exceptions, e.g., with elisp or java,
because (i) it was part of the design from the start, and (ii) the
execution machinery is aware of allocation and types of all objects.


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-devel mailing list