mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-18 05:04:41 +03:00
Casting away const isn't undefined behavior, but modifying a constant is (#1509)
* Casting away const isn't undefined behavior, but modifying a constant is You can cast away `const` as much as you like, as long as you never write to variable. * rewording for clarification
This commit is contained in:
@@ -11780,7 +11780,7 @@ for example.)
|
|||||||
##### Reason
|
##### Reason
|
||||||
|
|
||||||
It makes a lie out of `const`.
|
It makes a lie out of `const`.
|
||||||
If the variable is actually declared `const`, the result of "casting away `const`" is undefined behavior.
|
If the variable is actually declared `const`, modifying it results in undefined behavior.
|
||||||
|
|
||||||
##### Example, bad
|
##### Example, bad
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user