C and C++


LANG.STRUCT.DECL.EAWS : Extern Array Without Size

Summary

An array has a non-defining declaration that specifies extern linkage, but does not explicitly specify the array size.

Properties

Class Name Extern Array Without Size
Significance style
Mnemonic LANG.STRUCT.DECL.EAWS
Categories
MisraC2023 MisraC2023:8.11 When an array with external linkage is declared, its size should be explicitly specified
Misra2012 Misra2012:8.11 When an array with external linkage is declared, its size should be explicitly specified
Misra2004 Misra2004:8.12 When an array is declared with external linkage, its size shall be stated explicitly or defined implicitly by initialisation
AUTOSARC++14 AUTOSARC++14:A3-1-4 When an array with external linkage is declared, its size shall be stated explicitly.
  AUTOSARC++14:A18-1-1 C-style arrays shall not be used.
MisraC++2008 MisraC++2008:3-1-3 When an array is declared, its size shall either be stated explicitly or defined implicitly by initialization.
MisraC++2023 MisraC++2023:6.0.2 When an array with external linkage is declared, its size should be explicitly specified
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default, and require the unnormalized C ASTs for the project. To enable them, add the following WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Extern Array Without Size"
Note that retaining the unnormalized ASTs will increase the disk space used to store the project representation, and may make the analysis take longer.

Example

extern int extarrno[];            /* 'Extern Array Without Size' warning issued here */ 

extern int extarryes[4];                                          /* ok: size specified */

extern int extarrdef[] = {1,2,3};                                 /* ok: defining declaration */

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.