(C++) patch: C library fns don't throw

Andreas Jaeger aj@suse.de
Fri Mar 10 04:40:00 GMT 2000


>>>>> Jason Merrill writes on gcc-patches:

 > The standard tells us that functions inherited from the C library
 > don't throw, except possibly for bsearch and qsort.  Since there are
 > 209 such functions, I decided to use gperf to check for a match.

 > 2000-03-10  Jason Merrill  <jason@casey.cygnus.com>

 > 	C library functions don't throw.
 > 	* Makefile.in (cfns.h): New target.
 > 	(except.o): Depend on it.
 > 	* Make-lang.in (cc1plus): Depend on cfns.gperf.
 > 	* cfns.gperf: New file.
 > 	* cfns.h: Generated.
 > 	* except.c: Include it.
 > 	(nothrow_libfn_p): New fn.
 > 	* decl.c (grokfndecl): Use it.
 > 	* cp-tree.h: Declare it.

Jason, in the development version of glibc 2.2 we currently use for
example:
(from <stdio.h>:
extern FILE *tmpfile (void) __THROW;

and have in <sys/cdefs.h> the following:
/* GCC can always grok prototypes.  For C++ programs we add throw()
   to help it optimize the function calls.  But this works only with
   gcc 2.8.x and egcs.  */
# if defined __cplusplus && __GNUC_PREREQ (2,8)
#  define __THROW       throw ()
# else
#  define __THROW
# endif

With your changes, the __THROW seems to be not needed anymore for the
209 functions and we could remove them in theory.  Unfortunatly, glibc
has more than these functions, so we would need to check for each
function if it's one of those 209.  

I do think for glibc we shouldn't change anything and I hope g++ uses
the throw () which is added for all functions.  Does anybody see
another solution?

Andreas

P.S. I'm mailing this to libc-alpha and not to gcc-patches since this
is AFAIU a glibc issue.
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.rhein-neckar.de


More information about the Libc-alpha mailing list