MISRA C:2023 Rule 8.11
When an array with external linkage is declared, its size should be explicitly specified
Since R2024a
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.
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 R2024a