I’m not sure if the summary is the right way to say it, but the following C program fails a static assertion. Without the declaration at global scope it succeeds. struct Foo { int x; }; _Static_assert(sizeof(struct Foo) == sizeof(int), ""); void one(void){ struct Foo { int y, z; }; struct Foo f = {0}; _Static_assert(sizeof(struct Foo) == 2*sizeof(int), ""); struct Foo* pf = &f; pf->y = pf->z; } void two(void){ struct Foo { int y, z; } f = {0}; _Static_assert(sizeof(f) == 2*sizeof(int), ""); _Static_assert(sizeof(struct Foo) == 2*sizeof(int), ""); // fails // if you comment out the above assertion, then you get the error below struct Foo* pf = &f; pf->y = pf->z; // Error `y` is not a member of `Foo`. }
@WalterBright created dlang/dmd pull request #14806 "fix Issue 23407 - ImportC: function-local struct definition as part o…" fixing this issue: - fix Issue 23407 - ImportC: function-local struct definition as part of variable declaration doesn.t shadow global definition https://github.com/dlang/dmd/pull/14806
dlang/dmd pull request #14806 "fix Issue 23407 - ImportC: function-local struct definition as part o…" was merged into master: - 922c7b18c88ec3f6ad864d66867eb228838e2523 by Walter Bright: fix Issue 23407 - ImportC: function-local struct definition as part of variable declaration doesn.t shadow global definition https://github.com/dlang/dmd/pull/14806