www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22623] New: importC: forward reference to typedef'd struct

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 puremagic.com
          Reporter: duser 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)

--
Dec 22 2021