[Issue 22576] New: ImportC: cannot implicitly convert expression `S(0)` of type `S` to `int` in an S array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 7 07:24:00 UTC 2021


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

          Issue ID: 22576
           Summary: ImportC: cannot implicitly convert expression `S(0)`
                    of  type `S` to `int` in an S array
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dave287091 at gmail.com

The following C program fails to compile:

// compound.c
typedef struct S {
    int x;
} S;

int main(int argc, char** argv){
    S s = (S){0}; // ok
    S a0[] = {{0}}; // ok
    S a1[] = {(S){0}}; // Error: cannot implicitly convert expression `S(0)` of
type `S` to `int`
    struct S a2[] = {(struct S){0}}; // Error: cannot implicitly convert
expression `S(0)` of type `S` to `int`
    struct S a3[1] = {(struct S){0}}; // Error: cannot implicitly convert
expression `S(0)` of type `S` to `int`
}

--


More information about the Digitalmars-d-bugs mailing list