Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check array bounds for array parameters with static keyword #349

Open
ehaas opened this issue Jul 28, 2022 · 0 comments
Open

Check array bounds for array parameters with static keyword #349

ehaas opened this issue Jul 28, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@ehaas
Copy link
Collaborator

ehaas commented Jul 28, 2022

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]) {
             ^~~~~~~~~~~~
@Vexu Vexu added the enhancement New feature or request label Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants