Discussion:
[PATCH] strftime: don't use __THROW
(too old to reply)
Jim Meyering
2016-11-15 04:50:05 UTC
Permalink
Raw Message
I've just pushed the attached, to avoid new warnings when attempting
to build coreutils with the latest from gnulib:
Bruno Haible
2016-11-15 16:07:45 UTC
Permalink
Raw Message
Hi Jim,
Post by Jim Meyering
I've just pushed the attached, to avoid new warnings when attempting
+ strftime: don't use __THROW
+
+ lib/strftime.c:371:1: warning: '__leaf__' attribute has no effect \
+ on unit local functions [-Wattributes]
How is this going to be handled inside glibc? They have nearly the same
code in time/strftime_l.c, and they have the same definitions in <sys/cdefs.h>:

/* 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. For gcc 3.2 and up we even mark C functions
as non-throwing using a function attribute since programs can use
the -fexceptions options for C code as well. */
# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
# define __THROW __attribute__ ((__nothrow__ __LEAF))
# define __THROWNL __attribute__ ((__nothrow__))
# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct

I don't understand why you see this warning but the glibc developers
haven't noticed it yet??

Bruno
Paul Eggert
2016-11-15 16:46:18 UTC
Permalink
Raw Message
Post by Bruno Haible
I don't understand why you see this warning but the glibc developers
haven't noticed it yet??
I was puzzled about that too.

For what it's worth, those __THROWs were introduced to glibc in 2004 by
Ulrich Drepper, here:

https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=79937577d1e3e01b3fcc618366a9d7f78feed272

with no comment explaining why. Perhaps the compilers of the time
weren't smart enough to figure this stuff out automatically for static
functions. Anyway, the __THROWs should not be needed now. I verified
that they don't affect the code generated for x86-64 on Fedora 24 (gcc
Red Hat 6.2.1-2).

Loading...