Versions Compared

Key

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

...

It is common for an array variable to be initialized by a string literal and declared with an explicit bound that matches the number of characters in the string literal. Section 6.7.9, para. 14 [ISO/IEC 9899:2011], says:

An array of character type may be initialized by a character string literal or UTF−8 string literal, optionally enclosed in braces. Successive bytes of the string literal (including the terminating null character if there is room or if the array is of unknown size) initialize the elements of the array.

...

CERT C++ Secure Coding Standard: STR36-CPP. Do not specify the bound of a character array initialized with a string literal

ISO/IEC 9899:2011 Section  Section 6.7.9, "Initialization"

ISO/IEC TR 24772 "CJM String termination"

...