Is Reinterpret_Cast Undefined Behaviour?
2 Answers. Although the Reinterpret_Cast Itself Might Be Unspecified Behaviour, Attempting to Access the Parameters Once You've Done the Cast Is Undefined...
2 Answers. Although the reinterpret_cast itself might be unspecified behaviour, attempting to access the parameters once you've done the cast is undefined behaviour.
What is a reinterpret_cast?
reinterpret_cast is a type of casting operator used in C++. It is used to convert one pointer of another pointer of any type, no matter either the class is related to each other or not. It does not check if the pointer type and data pointed by the pointer is same or not.
Is const_cast undefined behavior?
Even though const_cast may remove constness or volatility from any pointer or reference, using the resulting pointer or reference to write to an object that was declared const or to access an object that was declared volatile invokes undefined behavior. So yes, modifying constant variables is undefined behavior.