A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char”
A string literal shall not be assigned to an object unless the object’s type is “pointer to const-qualified char”.
This rule prevents assignments that allow modification of a string literal.
An attempt to modify a string literal can result in undefined behavior. For example, some implementations can store string literals in read-only memory. An attempt to modify the string literal can result in an exception or crash.
The rule checker flags assignment of string literals to:
Pointers with data type other than const char*.
Arrays with data type other than const char.
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: Literals and Constants |
| Category: Required |
| AGC Category: Required |