-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Asterisk array size should be supported in typeof and _Atomic type specifiers which are part of a parameter declaration #90348
Comments
@llvm/issue-subscribers-clang-frontend Author: None (Halalaluyafail3)
Clang rejects the following declarations:
```c
void foo(typeof(int(*)[*])(*)[*]);
void bar(_Atomic(int(*)[*])(*)[*]);
```
> If the size is * instead of being an expression, the array type is a variable length array type of unspecified size, which can only be used as part of the nested sequence of declarators or abstract declarators for a parameter declaration, not including anything inside an array size expression in one of those declarators; (footnote) such arrays are nonetheless complete types.
>
> (foonote) They can be used only in function declarations that are not definitions (see 6.7.7.4 and 6.9.2).
These types should be accepted since the array type |
GCC bug report on this: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114873 . <source>(2): error: variable length array with unspecified bound is not allowed
void foo(typeof(int(*)[*])(*)[*]);
^
<source>(3): error: variable length array with unspecified bound is not allowed
void bar(_Atomic(int(*)[*])(*)[*]);
^ So 3 all reject it for the same reason. Which makes me suspect this is not valid. Note MSVC does not support [*] syntax so it is hard to test that. |
This wording changed recently N3096:
N3149 (maybe?) / N3220
DR#341 seems to ban N3070 is what prompted the wording change
I don't think it was intentional to allow those two declarations. |
That what is mentioned in the GCC bug report too https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114873#c4 |
…xts (reland #90438) (#91172) This relands #90348 with a fix for a [buildbot failure](https://lab.llvm.org/buildbot/#/builders/216/builds/38446) caused by the test being run with `-fno-rtti`.
I am in favor of allowing it. Conceptually it makes sense to allow it anywhere inside function prototype scope where a size expression is used, because this is what is for: replacing size expressions that could be invalid in a different context with a '*'. |
Clang rejects the following declarations:
These types should be accepted since the array type
[*]
is part of the nested sequence of declarators and abstract declarators for a parameter declaration.The text was updated successfully, but these errors were encountered: