D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22972 - importC: static variable cannot be read at compile time
Summary: importC: static variable cannot be read at compile time
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: ImportC, pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2022-04-02 20:57 UTC by duser
Modified: 2022-04-05 06:54 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description duser 2022-04-02 20:57:30 UTC
struct op {
	char text[4];
};
struct op ops[] = {
	{ "123" }
};
char *x[] = { ops[0].text };

Error: static variable `ops` cannot be read at compile time
Comment 1 Walter Bright 2022-04-05 04:21:29 UTC
Simplified:

struct op {
	char text[4];
};
struct op ops[] = {
	{ "123" }
};

char *y = ops[0].text;
Comment 2 Dlang Bot 2022-04-05 05:28:31 UTC
@WalterBright updated dlang/dmd pull request #13948 "fix Issue 22971 - importC: can't initialize unsigned char array with …" fixing this issue:

- fix Issue 22972 - importC: static variable cannot be read at compile time

https://github.com/dlang/dmd/pull/13948
Comment 3 Dlang Bot 2022-04-05 05:33:54 UTC
@WalterBright created dlang/dmd pull request #13949 "fix Issue 22972 - importC: static variable cannot be read at compile …" fixing this issue:

- fix Issue 22972 - importC: static variable cannot be read at compile time

https://github.com/dlang/dmd/pull/13949
Comment 4 Dlang Bot 2022-04-05 06:54:00 UTC
dlang/dmd pull request #13949 "fix Issue 22972 - importC: static variable cannot be read at compile …" was merged into master:

- 0072b8ad6251c57d78651baa0ca7ff6adda60f71 by Walter Bright:
  fix Issue 22972 - importC: static variable cannot be read at compile time

https://github.com/dlang/dmd/pull/13949