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:


Undefined behavior:
* Result of some reinterpret_cast conversions

Table Of Contents
8 Arrays
11 Loops
39 Streams
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
71 Undefined behavior
84 RTTI
87 Scopes
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype