I've been carefully reading over the rules for type aliasing: http://en.cppreference.com/w/cpp/language/reinterpret_cast#Type_aliasing I specifically have a question about the last rule, wherein we are allowed to cast to:
char
orunsigned char
: this permits examination of the object representation of any object as an array ofunsigned char
I've noted that this does not include the void
type. Shouldn't we be able to cast anything to void
and back too?
There's no type aliasing in that case, because you can't examine an object through a void*
. To do so, you'd have to dereference the void*
, but that is disallowed. void
in any context is an incomplete type, and you can't dereference pointers to incomplete types.