3 ms·
GCC just happens to not even print a warning about this (even with -Wall). That is pretty bad. The warning can be enabled by specifying -Wpointer-arith or by us
by apaprocki 15y ago
GCC just happens to not even print a warning about this (even with -Wall). That is pretty bad. The warning can be enabled by specifying -Wpointer-arith or by using -pedantic, though. (Warning: "invalid application of 'sizeof' to a void type")
IBM's xlc compiler produces a warning and compiles the code and it also returns 1. (Warning: "1506-043 (W) The operand of the sizeof operator is not valid.")
Oracle Studio compiler has the best approach and fails to compile. (Error: "cannot take sizeof void")