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

static qualifier in array parameter declaration #531

Closed
monniaux opened this issue Oct 29, 2024 · 1 comment · Fixed by #539
Closed

static qualifier in array parameter declaration #531

monniaux opened this issue Oct 29, 2024 · 1 comment · Fixed by #539

Comments

@monniaux
Copy link
Contributor

C99 §6.7.5.3-7 states that static in an array parameter declaration means

If the keyword static also appears within the [ and ] of the
array type derivation, then for each call to the function, the value of the corresponding
actual argument shall provide access to the first element of an array with at least as many
elements as specified by the size expression.

Thus the following should be accepted:

int foo5(int t[static 1]) {
  return t[0];
}

int foo6(int t[const static 1]) {
  return t[0];
}

I suspect the simplest is to ignore this keyword. (Technically, one could use it to convey semantic information that the area pointed to should be accessible for a certain length, thus allowing some optimizations such as speculatively loading values, but this would require quite a bit of work…)

xavierleroy added a commit that referenced this issue Nov 29, 2024
E.g. `int x[static 10]` or `int x [*]`.
Treated like `int x[10]` and `int x[]` respectively.

Fixes: #531
@xavierleroy
Copy link
Contributor

Tentative fix at #539.

xavierleroy added a commit that referenced this issue Nov 30, 2024
E.g. `int x[static 10]` or `int x [*]`.
Treated like `int x[10]` and `int x[]` respectively.

Fixes: #531
xavierleroy added a commit that referenced this issue Dec 2, 2024
E.g. `int x[static 10]` or `int x [*]`.
Treated like `int x[10]` and `int x[]` respectively.

Fixes: #531
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants