[PPL-devel] Re: Feature request: optionally compile with support for exceptions

Niels Möller nisse at lysator.liu.se
Tue Oct 23 09:59:36 CEST 2001


Roberto Bagnara <bagnara at cs.unipr.it> writes:

> it would be nice to be able to write `--enable-exceptions' in the
> GMP configure command line so that, if GMP is compiled with GCC,
> the `-fexceptions' option is used.  This is necessary to have,
> e.g., `bad_alloc' thrown when virtual memory is exhausted and most
> serious C++ GMP users will want to do that.  Of course, the default
> can/should be `--disable-exceptions'.

I think that having compile time options that change these kinds of
behaviour is asking for trouble. Sooner or later you'll have a system
where GMP is installed, and you don't know which way it was compiled,
or you have both variants installed in different places and
accidentally link with the wrong one. And it probably gets even worse
with dynamic linking.

If you want exception raising to be optional, I think you should put
the two variants into different namespaces, and then you can have
compile time options for building either or both variants.

An alternative is of course to "always" build with exceptions, and say
that the GMP C++ ABI includes raising exceptions under certain
circumastances. You could leave a compile time option for disabling
exceptions (changing the ABI), but then you'd have to shoot any
distributor that ships GMP libraries compiled in that incompatible
way.

(And at last, you should be able to get what you want with

  CXXFLAGS=-fexceptions && ./configure && make

without using any new configure options).

/Niels



More information about the PPL-devel mailing list