This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]