error handling
Victor Shoup
shoup at cs.nyu.edu
Mon Nov 10 19:16:48 UTC 2014
Hi Marc,
Thanks for your reply.
Yes, the idea suggested in your other post would be a very good start,
and presumably not too difficult to do for someone who knows their
way around GMP. I myself am facing a rather daunting task for
making my own library exception safe, so there is certainly no rush.
I guess systems like Sage and others that build ob GMP (and NTL)
would benefit from better error handling. Time to move (slowly) into the
21st century...
-Victor
On Nov 10, 2014, at 1:43 PM, Marc Glisse wrote:
> 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