I’m using the following flags, but still I m not able to get this warning:
pointer of type
void *used in arithmetic
Flags used:
-O2 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-sign-compare -Wno-pointer-sign -Wno-attributes -fno-strict-aliasing
-Wpointer-arith should catch this type of warning, but I’m not able to get this warning:
pointer of type
void *used in arithmetic
Which specific cflag should be used to get this warning?
Edit: my mistake, it is there as part of a macro check which is not defined. 🙁 By defining that macro, I’m able to get that error.
You’re right.
-Wpointer-arithshould give you a warning as per the documentation.I have just tried the following program (with intentional error):
I have compiled the program with just the
-Wpointer-arithoption, and all your options as listed above. Both attempts threw up the desired warning. I am using gcc version 4.3.4 (Debian 4.3.4-6).:and
The compiler does throw up the warning if you give it the ‘right’ code. So, I would recommend you examine why it is you expect this warning. Maybe the code you’re compiling has changed?
One possible clue I can give you:
foo = bar + 1;in the code above triggers the warning. Butfoo = bar ++;will not (You get a different warning). So if your code uses increment (or decrement) operators on pointers, it will probably not trigger the warning.I know this is not a direct answer, but I hope this helps you focus your investigation.