Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC2004-8.12

In this section:
Synopsis

(Required) When an array is declared with external linkage, its size shall be stated explicitly or defined implicitly by initialization.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

External arrays are declared without their size being stated explicitly or defined implicitly by initialization. This check is identical to MISRAC++2008-3-1-3, MISRAC2012-Rule-8.11, 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 };