c_std/ and throw()

Jakub Jelinek jakub@redhat.com
Wed Apr 11 05:47:00 GMT 2001


Hi!

The c_std/ headers throw away the carefully maintained throw()
lists glibc maintains in its installed headers for functions which cannot
throw.
IMHO this is bad and results in worse code generation.
What do you think about following approach (just a RFC, not complete patch)?
libstdc++-v3 configure would check if glibc headers use throw() for
functions libstdc++-v3 expects (IMHO doing it on a per-function basis would
be overkill, so I think it is better to check always some category of
functions and if all have throw() specified, define some _GLIBCPP_*THROW
macro accordingly).
The attached patch uses 3 different categories, most functions, math
functions (e.g. glibc 2.1.x don't use throw() for them) and for wide
character functions (even glibc 2.2.2 doesn't declare them all with
throw()).
For testing, attached are 3 programs which if they give no errors/warnings
mean the corresponding _GLIBCPP_*_THROW should be defined to throw(),
otherwise to nothing. Some functions cannot be easily tested without
detailed libc knowledge (to test if glibc has throw() one must write
prototype with throw() before including the glibc header), but it is assumed
if the other similar functions which are tested are having throw() that they
do as well.
I wonder whether the tests should be put with cat <<EOF into acinclude.m4 or
whether they should be put into separate files and acinclude.m4 macros would
just compile them.

Also, I haven't seen __attribute__ used in libstdc++-v3 headers but
libsupc++, is it allowable to use them there? If yes, some functions could
be marked with __attribute__((pure)) or __attribute__((noreturn)).

	Jakub


More information about the Libstdc++ mailing list