This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Builtin expansion versus headers optimization: Reductions
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Mikhail Maltsev <maltsevm at gmail dot com>
- Cc: Andi Kleen <andi at firstfloor dot org>, Ondřej Bílka <neleai at seznam dot cz>, <gcc at gcc dot gnu dot org>, <libc-alpha at sourceware dot org>
- Date: Fri, 5 Jun 2015 17:11:33 +0000
- Subject: Re: Builtin expansion versus headers optimization: Reductions
- Authentication-results: sourceware.org; auth=none
- References: <20150604105929 dot GA19141 at domone> <87fv67nonj dot fsf at tassilo dot jf dot intel dot com> <55713309 dot 6070300 at gmail dot com>
On Fri, 5 Jun 2015, Mikhail Maltsev wrote:
> There are other issues with macros in glibc headers (well, not as
> significant as performance-related concerns, but never the less).
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24016#c3
>
> > #include <string.h>
> > int foo(void *x) {
> > return strcmp(x + 1, "test");
> > }
> >
> > does not cause warnings when compiled with -Wpointer-arith -O1
> > (glibc v. 2.17). It can be reduced to:
> >
> > int foo(void *x) {
> > return __extension__({ __builtin_strcmp(x + 1, "test"); });
> > }
>
> In this case __extension__ inhibits -Wpointer-arith, because void*
> arithmetics is a valid GNU extension, but the user does not even know
> that he is using it.
In <https://gcc.gnu.org/ml/gcc/2001-04/msg00642.html> I suggested
__unextension__ to allow macros to avoid suppressing such warnings inside
the expansion of macro arguments (given that feature, lots of macro
definitions would then need to change to use __unextension__ (ARG) instead
of just (ARG)).
--
Joseph S. Myers
joseph@codesourcery.com