[Issue 22623] New: importC: forward reference to typedef'd struct inside struct creates incompatible type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 22 22:52:24 UTC 2021


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

          Issue ID: 22623
           Summary: importC: forward reference to typedef'd struct inside
                    struct creates incompatible type
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: duser at airmail.cc

---
struct first_s {
        struct second_s *child;
};

typedef struct second_s {
        int xyz;
} second_t;

void fn()
{
        struct first_s v1;
        struct second_s v2;
        if (v1.child != &v2) // error
                ;
}
---

output:

---
test.c(13): Error: incompatible types for `(v1.child) !is (& v2)`:
`test.first_s.second_s*` and `test.second_s*`
---

the error goes away if the typedef around the second struct is removed

seen with DMD64 D Compiler v2.098.0-361-g415e58e6d (current git master)

--


More information about the Digitalmars-d-bugs mailing list