arocc
arocc copied to clipboard
Check array bounds for array parameters with `static` keyword
void foo(int x[static 10]) {
}
void bar(void) {
int x[5];
foo(x);
}
clang warns:
test.c:7:5: warning: array argument is too small; contains 5 elements, callee requires at least 10 [-Warray-bounds]
foo(x);
^ ~
test.c:1:14: note: callee declares array parameter as static here
void foo(int x[static 10]) {
^~~~~~~~~~~~