This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Default warnings and useless extensions (e.g. arithmetic on void *)
- From: Vincent Lefevre <vincent+gcc at vinc17 dot org>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 9 Jun 2008 15:46:06 +0200
- Subject: Default warnings and useless extensions (e.g. arithmetic on void *)
Is there any reason why "gcc -Wall" doesn't emit warnings by default
on some useless extensions such as pointer arithmetic on (void *)?
IMHO, such an extension is useless because there's an easy workaround:
use casts to char *. And since g++ barfs on pointer arithmetic on
void *, such a warning would be very useful. BTW, gcc is also silent
when -Wc++-compat is used! With gcc/g++ 4.3.1:
vin% cat ptrarith.c
void *foo (void *p)
{
return p + 1;
}
vin% gcc -Wall -Wc++-compat -c ptrarith.c
vin% g++ -c ptrarith.c
ptrarith.c: In function 'void* foo(void*)':
ptrarith.c:3: error: pointer of type 'void *' used in arithmetic
vin%
So, basically shouldn't -Wpointer-arith (and possible other ones) be
added to the options enabled by -Wall?
--
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)