www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24274] New: [REG master] ImportC: unrecognized C initializer

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

          Issue ID: 24274
           Summary: [REG master] ImportC: unrecognized C initializer with
                    array in struct
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC, rejects-valid
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

Introduced by https://github.com/dlang/dmd/pull/15891

```C
struct S0
{
    struct
    {
        char short_data[24];
    };
    int length;
};

struct S0 s0 = {{.short_data = {0}}, .length = 0};
```

Error: `[ constant-expression ]` expected for C array element initializer
`{.short_data={0}}`


```C
struct S1
{
    struct
    {
        char* long_data;
        char short_data[24];
    };
    int length;
};

struct S1 s1 = {{.short_data = {0}}, .length = 0};
```

Error: unrecognized C initializer `{.short_data={0}}`

--
Dec 08 2023