MISRA C:2012 Rule 8.11
When an array with external linkage is declared, its size should be explicitly specified
Description
Rule Definition
When an array with external linkage is declared, its size should be explicitly specified.
Rationale
Although it is possible to declare an array with an incomplete type and access its elements, it is safer to state the size of the array explicitly. If you provide size information for each declaration, a code reviewer can check multiple declarations for their consistency. With size information, a static analysis tool can perform array bounds analysis without analyzing more than one unit.
Polyspace Implementation
The rule checker flags arrays declared with the extern
specifier if the declaration does not explicitly specify the array size.
Additional Message in Report
Size of array array_name
should be explicitly stated. When an array
with external linkage is declared, its size should be explicitly specified.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Declarations and Definitions |
Category: Advisory |
AGC Category: Advisory |
Version History
Introduced in R2014b