...
Footnote 103 in subclause 6.5.3.4 of the C Standard [ISO/IEC 9899:2011] explainsapplies to all array parameters:
When applied to a parameter declared to have array or function type, the
sizeofoperator yields the size of the adjusted (pointer) type.
This applies to all array parameters.
Compliant Solution
In this compliant solution, the size of the array is determined inside the block in which it is declared and passed as an argument to the function:
...
In this noncompliant code example, the sizeof a does not equal 100 * sizeof(int) because the sizeof operator, when applied to a parameter declared to have array or function type, yields the size of the adjusted (pointer) type , even if the parameter declaration specifies a length:
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
ARR01-C | highHigh | probableProbable | lowLow | P18 | L1 |
Automated Detection
Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
|
| Can detect violations of the recommendation but cannot distinguish between incomplete array declarations and pointer declarations | |||||||
| 401 S | Partially implemented | |||||||
|
|
|
...