C++ type casting. When will static_cast succeed and reinterpret_cast will cause an issue?

Viewed 1980

I understand that a static_cast is a cast from one type to another that (intuitively) is a cast that could under some circumstance succeed and be meaningful in the absence of a dangerous cast. Meanwhile, a reinterpret_cast is a cast that represents an unsafe conversion that might reinterpret the bits of one value as the bits of another value.

Can someone describe a scenario when the code will compile, cast and static_cast will cause no issue, but with reinterpret_cast there will be an issue?

3 Answers
Related