casting from T1 * to unrelated T2 * with reinterpret_cast is no less defined than with static_cast. In fact, when both T1 and T2 are standard layout types, it works the same way (see 5.2.10 / 7):
When prvalue v of type "pointer to T1" is converted to a pointer of type "to cv T2", the result is static_cast <cv T2 *> (static_cast <cv is invalid *> (v))
For custom layout types, the conversion result is not specified, but it is also not set for static_cast.
I assume that you can only get the difference when casting non-index types in such artificial cases:
struct Foo { }; struct Bar { operator void*() { return 0; } }; int main () { Bar b; Foo * p1 = static_cast<Foo*>(static_cast<void *>(b));
struct Foo { }; struct Bar { operator void*() { return 0; } }; int main () { Bar b; Foo * p1 = static_cast<Foo*>(static_cast<void *>(b));
Konstantin Oznobihin
source share