C does not define sizeof for functions. The expression sizeof voo violates the constraint and requires diagnostics from any relevant C compiler.
gcc implements pointer arithmetic on function pointers as an extension. To support this, gcc arbitrarily assumes that the size of the function is 1, so adding, say 42 to the function address will give you the address 42 bytes after the function address.
They did the same for void, so sizeof (void) gives 1, and void* pointer arithmetic is allowed.
Both functions are best avoided if you want to write portable code. Use -ansi -pedantic or -std=c99 -pedantic to get warnings about this.
Keith thompson
source share