Dennis 2023-12-12 23:04:37 UTC submitted:
Another example: (not sure if it's the same bug)
a.c
```C
typedef struct {} Slice;
struct Lang
{
Slice *slices;
};
```
b.c
```C
typedef struct {} Slice;
struct Lang
{
Slice *slices;
};
void langmap(struct Lang *self)
{
Slice slice = *self->slices;
}
```
```
dmd a.c // works
dmd b.c // works
dmd b.c a.c // works
dmd a.c b.c // fails:
b.c(11): Error: cannot implicitly convert expression `*(*self).slices` of type `__tag2` to `__tag3`
```
Comment #1 by bugzilla — 2023-12-27T09:29:18Z
This is a victim of the compiler adding the missing tag name for the anonymous struct, but generating a different name for the two definitions. The type of the struct is keyed off of the tag name - so different tag names mean different types.
The solution is to generate the same tag name for each. I have an idea how to do that by making use of the typedef identifier.
Comment #2 by dlang-bot — 2023-12-28T08:18:41Z
@WalterBright created dlang/dmd pull request #15958 "fix Issue 24303 - anonymous struct problems when typedef'd in separat…" fixing this issue:
- fix Issue 24303 - anonymous struct problems when typedef'd in separate C files
https://github.com/dlang/dmd/pull/15958
Comment #3 by dlang-bot — 2023-12-29T03:55:54Z
dlang/dmd pull request #15958 "fix Issue 24303 - anonymous struct problems when typedef'd in separat…" was merged into master:
- 135e3c07b2c2548ecec0ea00478f5e1e2191947c by Walter Bright:
fix Issue 24303 - anonymous struct problems when typedef'd in separate C files
https://github.com/dlang/dmd/pull/15958