www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23718] New: runnable/initializer.c:583:10: error: cast

https://issues.dlang.org/show_bug.cgi?id=23718

          Issue ID: 23718
           Summary: runnable/initializer.c:583:10: error: cast specifies
                    array type
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

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__);
}
```

--
Feb 15 2023