www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23030] New: importC: errors using typedef struct after first

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

          Issue ID: 23030
           Summary: importC: errors using typedef struct after first use
                    as const
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC, rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: duser neet.fi
                CC: duser neet.fi

// test1.c
typedef struct {
    int i;
} S1;
const S1 unused;
S1 s;
void fn() { int i = s.i; } // Error: need `this` for `i` of type `int`

// test2.c
typedef struct {
    int a,b;
} S2;
const S2 aaa = { 0,0 };
S2 bbb = { 0,0 }; // Error: 1 extra initializer(s) for `struct __tag3`

both bisected to https://github.com/dlang/dmd/pull/13990

--
Apr 17 2022