The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements
The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements.
If you use an array declarator for a function parameter instead of a pointer, the function interface is clearer because you can state the minimum expected array size. If you do not state a size, the expectation is that the function can handle an array of any size. In such cases, the size value is typically another parameter of the function, or the array is terminated with a sentinel value.
However, it is legal in C to specify an array size but pass an array of smaller size. This rule prevents you from passing an array of size smaller than the size you declared.
The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements.
The argument type has elements
whereas the parameter type expects actual_size elements.expected_size
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: Functions |
| Category: Advisory |
| AGC Category: Readability |