This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
__extension__ doesn't affect -Wpointer-arith
- To: gcc-bugs at gcc dot gnu dot org
- Subject: __extension__ doesn't affect -Wpointer-arith
- From: Jim Kingdon <kingdon at redhat dot com>
- Date: Mon, 30 Aug 1999 16:28:35 -0400
The -Wpointer-arith option becomes useless (or at least, painful to
use) with -O and glibc 2.1.2pre3 because bits/string2.h in the latter
uses pointer arithmetic on void * and __extension__ only turns off
-pedantic, not -Wpointer-arith.
For the reaction of Ulrich Drepper (libc maintainer), see:
http://sourceware.cygnus.com/ml/libc-alpha/1999-08/msg00113.html
Seems to me that having __extension__ affect -Wpointer-arith would
make sense.
Here's an example, for those who don't feel like downloading the whole
libc in question :-):
bash$ gcc -pedantic foo3.c
bash$ gcc -Wpointer-arith foo3.c
foo3.c: In function `main':
foo3.c:10: warning: pointer of type `void *' used in arithmetic
bash$ cat foo3.c
#include <stdio.h>
int
main (int argc, char **argv)
{
union {
char b;
int y;
} *__u = (void *) &argc;
__u = __extension__ ((void *)__u + 1);
printf ("%d\n", __u->b);
return 0;
}
bash$