GMP terminates when out of memory

Torbjorn Granlund tg at
Fri Dec 26 18:23:20 CET 2008

"Bjarke Roune" <bjarke at> writes:

  > What sort of behaviour would you suggest?
  > I suppose much of this can be done with the custom allocation interface
  > already.
  A reasonable behavior would be to return an error code or set an error

Who should return that and to whom should it be returned?

And what about reentrancy?

  The C++ interface could check for error and throw an exception.
  The harder part of this is to make sure that GMP responds to failure
  by putting the objects involved in the computation into some valid
  state and then returns without leaking memory. In the case of the
  library I am working on, this kind of thing turned out to be more
  tricky than I had thought.

Error handling can be really tricky.


More information about the gmp-discuss mailing list