Yes, obviously.
(void)p;
means the object is getting casted to void
type, (which is not a complete type) and that being the complete expression, the result of the expression should not be used, hence compiler does not check for it's usage.
Quoting C11
standard, chapter 6.3.2.2, void
The (nonexistent) value of a void
expression (an expression that has type void) shall not
be used in any way,[......] If an expression of any other type is evaluated as a void
expression, its value or designator is discarded.
So, no warning or error is generated.
OTOH,
(void *)p;
means the object is a pointer to void
type, which is a complete type and should be used in your program. In that case, the non-usage of the object out of the expression is rightly reported by the compiler.