The following valid C code fails to compile: // staticvar.c int x = 0; int* y = &x; // ok struct Foo { int x; }; struct Foo f = {3}; int* z = &f.x; // error The message is: staticvar.c(10): Error: static variable `f` cannot be read at compile time
The equivalent D code also fails to compile, but I don’t know if that is according to spec or not.
@WalterBright created dlang/dmd pull request #13334 "fix Issue 22513 - ImportC: address of member of struct cannot be take…" fixing this issue: - fix Issue 22513 - ImportC: address of member of struct cannot be taken at compile time https://github.com/dlang/dmd/pull/13334
dlang/dmd pull request #13334 "fix Issue 22513 - ImportC: address of member of struct cannot be take…" was merged into stable: - a84806c2adf478cb27120d6817f2d384d62f6a2c by Walter Bright: fix Issue 22513 - ImportC: address of member of struct cannot be taken at compile time https://github.com/dlang/dmd/pull/13334
dlang/dmd pull request #13421 "merge stable" was merged into master: - 0044dfd0bd91a5b420e8edab7cd6aff28e6e6e7b by Walter Bright: fix Issue 22513 - ImportC: address of member of struct cannot be taken at compile time https://github.com/dlang/dmd/pull/13421