error handling
Marc Glisse
marc.glisse at inria.fr
Mon Nov 10 18:43:00 UTC 2014
On Mon, 10 Nov 2014, Victor Shoup wrote:
> I know that this subject has come up before, but I was wondering if there
> are any updates.
Not that I know :-(
> I maintain a C++ library (NTL) that uses GMP for long integer arithmetic.
> While NTL itself currently has very primitive error handling (print to stderr and abort),
> I'm investigating the possibility of making it use exceptions that client code could
> potentially deal with. One obsticle to this is GMP's error handling.
> In my particular situation, NTL only uses GMP at the mpn layer, so much of
> the memory management is done by NTL (although I presume even the mpn
> layer of GMP needs to allocate memory for temporaries).
>
> So I'm wondering if there is any hope in the future of GMP offering
> alternative error handling strategy? I know that GMP is "pure C",
> but perhaps it could nevertheless be updated so that with judicious
> use of macros, it could be compiled as a C++ library that would
> throw exceptions in an appropriate manner.
Being able to compile GMP as C++ is officially a goal, at least for
testing purposes so we can more easily experiment with unusual limb sizes.
Note that you can already tell GMP to use your allocator, which can throw
exceptions, and if gmp was compiled with gcc -fexceptions, they will
propagate. Some memory will leak in that case though.
I am still planning to implement the second paragraph of this message:
https://gmplib.org/list-archives/gmp-devel/2012-February/002210.html
but as you can guess from the date you shouldn't hold your breath...
Though it is simple enough that I may do it this winter.
--
Marc Glisse
More information about the gmp-discuss
mailing list