MISRAC2012-Rule-8.11
Synopsis
(Advisory) When an array with external linkage is declared, its size should be explicitly specified.
Enabled by default
No
Severity/Certainty
Low/Medium

Full description
One or more external arrays are declared without their size being stated explicitly or defined implicitly by initialization. This check is identical to MISRAC2004-8.12, MISRAC++2008-3-1-3, MISRAC++2023-6.0.2.
Coding standards
- MISRA C:2004 8.12
(Required) When an array is declared with external linkage, its size shall be stated explicitly or defined implicitly by initialization.
- MISRA C:2012 Rule-8.11
(Advisory) When an array with external linkage is declared, its size should be explicitly specified
- MISRA C++ 2008 3-1-3
(Required) When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization.
- MISRA C++ 2023 6.0.2
(Advisory) When an array with external linkage is declared, its size should be explicitly specified
Code examples
The following code example fails the check and will give a warning:
extern int a[];
The following code example passes the check and will not give a warning about this issue:
extern int a[10];
extern int b[] = { 0, 1, 2 };