Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

At compile time, string literals are used to create an array of static storage duration of sufficient length to contain the character sequence and a null-termination character. It is unspecified whether these arrays are distinct. The behavior is undefined if a program attempts to modify string literals but frequently results in an access violation because string literals are typically stored in read-only memory. See also undefined behavior 33  of Annex J of the C standard [ISO/IEC 9899:2011].

Do not attempt to modify a string literal. Use a named array of characters to obtain a modifiable string.

...

CERT C++ Secure Coding Standard: STR30-CPP. Do not attempt to modify string literals

ISO/IEC 9899:2011 Section  Section 6.4.5, "String literals"

ISO/IEC TR 17961 (Draft) Modifying string literals [strmod]

...