Using GCC -Wpointer-arith

GCC documentation says

-Wpointer-Arith Warn about anything that depends on the "size" of the function type or the "void". GNU C assigns these types to size 1, for the convenience of calculations with void * pointers and function pointers. In C ++, also warn that arithmetic operations use "NULL".

But I can’t figure out where it can be useful, and not create trouble. Any examples?

+6
source share
1 answer

All of these operations are undefined according to the C standard. This warning is useful for indicating situations where the code may work under GCC but will fail with other compilers.

+2
source

All Articles