D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22513 - ImportC: address of member of struct can’t be taken at compile time.
Summary: ImportC: address of member of struct can’t be taken at compile time.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: ImportC, pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2021-11-14 22:43 UTC by dave287091
Modified: 2021-12-14 10:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description dave287091 2021-11-14 22:43:08 UTC
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
Comment 1 dave287091 2021-11-14 22:58:47 UTC
The equivalent D code also fails to compile, but I don’t know if that is according to spec or not.
Comment 2 Dlang Bot 2021-11-21 09:39:58 UTC
@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
Comment 3 Dlang Bot 2021-11-23 03:02:21 UTC
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
Comment 4 Dlang Bot 2021-12-14 10:34:23 UTC
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