Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Code Block
int array[] = {1, 2, 3}; /* 3-element array */

Wiki Markupbut it is also possible to use designators to initialize array elements in a noncontiguous fashion. C99, Section 6.7.8, \[ [ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] states

Space can be "allocated" from both ends of an array by using a single designator:

Code Block
int a[MAX] = {
  1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0
};

In the above, if MAX is greater than ten, there will be some zero-valued elements in the middle; if it is less than ten, some of the values provided by the first five initializers will be overridden by the second five.

...

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

ARR02-C

medium

unlikely

low

P6

L2

Automated Detection

Tool

Version

Checker

Description

Section

Compass/ROSE

 

 

 

Section

LDRA tool suite

Include Page
c:LDRA_Vc:
LDRA_V
Section

127 S
397 S
404 S

Section

Partially Implemented

Section

ECLAIR

Include Page
c:ECLAIR_Vc:
ECLAIR_V
Section

araydecl

Section

Fully Implemented

...