When compiling the test with `gcc -std=c11 -fsyntax-only`
runnable/initializer.c: In function ‘test38a’:
runnable/initializer.c:583:10: error: cast specifies array type
583 | i = ((int[3])a)[2];
| ^
Original test:
```
void test38a()
{
int i;
static int a[3] = { 1,2,3 };
// Casting to an array type is not allowed by C11, but
// CompoundLiterals are not there yet to test this
// grammar
i = ((int[3])a)[2];
assert(i == 3, __LINE__);
}
```
Comment #1 by bugzilla — 2023-12-02T02:32:48Z
int a[3] in C specifies a static array, and the cast is converting a static array with 3 elements to a static array with 3 elements, i.e. the cast is a no-op, which is likely why it succeeds.
Comment #2 by bugzilla — 2023-12-14T06:42:12Z
Why is this marked as major? It's a very minor extension. I don't see an issue with leaving it as it is.
Comment #3 by robert.schadek — 2024-12-13T19:27:20Z