Result of some reinterpret cast conversions

suggest change

The result of a reinterpret_cast from one function pointer type to another, or one function reference type to another, is unspecified. Example:

int f();
auto fp = reinterpret_cast<int(*)(int)>(&f); // fp has unspecified value

The result of a reinterpret_cast from one object pointer type to another, or one object reference type to another, is unspecified. Example:

int x = 42;
char* p = reinterpret_cast<char*>(&x); // p has unspecified value

However, with most compilers, this was equivalent to static_cast<char*>(static_cast<void*>(&x)) so the resulting pointer p pointed to the first byte of x. This was made the standard behavior in C++11. See type punning conversion for more details.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents