Bug 23718 – runnable/initializer.c:583:10: error: cast specifies array type

Status
NEW
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2023-02-15T17:43:14Z
Last change time
2024-12-13T19:27:20Z
Keywords
accepts-invalid, ImportC
Assigned to
No Owner
Creator
Iain Buclaw
Depends on
23689
See also
https://issues.dlang.org/show_bug.cgi?id=23689
Moved to GitHub: dmd#20233 →

Comments

Comment #0 by ibuclaw — 2023-02-15T17:43:14Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20233 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB