arocc icon indicating copy to clipboard operation
arocc copied to clipboard

Check array bounds for array parameters with `static` keyword

Open ehaas opened this issue 3 years ago • 0 comments

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]) {
             ^~~~~~~~~~~~

ehaas avatar Jul 28 '22 06:07 ehaas