reinterpret_cast<>
with pointers to void
It's not well known, but in fact
it's not actually legal to use reinterpret_cast<> with
pointers to void
in C++.
This is perhaps best regarded as a defect in the C++ Standard. Here's an additional paragraph to add to §5.2.10 that would fix this:
A pointer to an object type can be explicitly converted to a pointer to void, and vice versa.1 The result of such a pointer conversion will have the same result as the standard pointer conversion described in §4.10. A value of type “pointer to object” converted to “pointer to void” and back, possibly with different cv-qualification, shall have its original value.
1
The types may have different cv-qualifiers, subject to the overall
restriction that a reinterpret_cast
cannot cast away
constness.