Weird Behaviour with const_cast [duplicate]

The program has undefined bahaviour because you may not change a const object.

From the C++ Standard

4 Certain other operations are described in this International
Standard as undefined (for example, the effect of attempting to modify
a const object
). [ Note: This International Standard imposes no
requirements on the behavior of programs that contain undefined
behavior. —end note ]

Leave a Comment