[Issue 24251] New: Spurious forward reference error with nested struct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 19 21:55:59 UTC 2023


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

          Issue ID: 24251
           Summary: Spurious forward reference error with nested struct
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: andy.pj.hanson at gmail.com

```
struct A {
        B b;
}

struct B {
        struct Inner {
                C c;
        }
}

struct C {
        A a;
}
```

This results in the error:
```
a.d(12): Error: struct `a.A` no size because of forward reference
```

There's no need for this error, since an instance of B doesn't actually contain
a C.
Just like there is no error in this simpler case:

```
struct A {
        struct Inner {
                B b;
        }
}

struct B {
        A a;
}
```

I discovered this when chasing a sporadic forward reference error that appeared
when changing unrelated code.

--


More information about the Digitalmars-d-bugs mailing list