MISRA C++:2008 Rule 3-1-3
When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization
Description
Rule Definition
When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization.
Rationale
Declaring an array with external linkage without specifying its size and then attempting to access elements of the array can result in an array index out of bounds error. To reduce the possibility of such errors, specify the size of an array in its declaration.
Polyspace Implementation
Polyspace® reports a violation of this rule if all of these conditions are true:
You declare an
extern
array.The array is not initialized.
The number of elements for the array is not explicitly stated.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Basic Concepts |
Category: Required |
Version History
Introduced in R2013b