// file1.c
struct S1 {
int field1;
};
struct S1 *const unused;
// file2.c
struct S2 {
int field2;
};
void fn()
{
struct S2 *const s;
int x = s->field2; // here
}
compile: dmd file1.c file2.c
file2.c(7): Error: `field2` is not a member of `const(S1)`
similar to issue 23030 but not caused by the same PR (this exists on stable v2.099.1 too)
Comment #1 by bugzilla — 2022-04-20T04:40:09Z
Ah, took me hours to track this one. The trouble is addSTC() to add in a `const`. In D, this works because type names are identifiers, and mangling is skipped for TypeIdentifier. In C, these come through as a TypeTag, which does get mangled, but semantic() hasn't been run, so S1 and S2 both mangle as "x@" and are therefore treated as the same type.
Comment #2 by dlang-bot — 2022-04-20T04:55:38Z
@WalterBright created dlang/dmd pull request #14016 "fix Issue 23034 - importC: head-const struct confused with multiple f…" fixing this issue:
- fix Issue 23034 - importC: head-const struct confused with multiple files on command line
https://github.com/dlang/dmd/pull/14016
Comment #3 by dlang-bot — 2022-04-20T08:30:43Z
dlang/dmd pull request #14016 "fix Issue 23034 - importC: head-const struct confused with multiple f…" was merged into master:
- 62c0846dd48cef8cf032a552c3e43c18565c42ea by Walter Bright:
fix Issue 23034 - importC: head-const struct confused with multiple files on command line
https://github.com/dlang/dmd/pull/14016