D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3620 - Address of member of global struct isn't constant
Summary: Address of member of global struct isn't constant
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-12-16 07:10 UTC by FeepingCreature
Modified: 2019-08-10 18:33 UTC (History)
3 users (show)

See Also:


Attachments
Make address of member of global struct constant (600 bytes, patch)
2009-12-16 07:10 UTC, FeepingCreature
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description FeepingCreature 2009-12-16 07:10:47 UTC
Created attachment 524 [details]
Make address of member of global struct constant

When taking the address of a member of a global struct, as in

struct S { int x; }

S s;

const int* p = &s.x;

The above fails on 1.051 with "Error: non-constant expression &s.x"

The attached patch fixes this.
Comment 1 FeepingCreature 2009-12-23 21:31:08 UTC
Nevermind, seems it breaks Tango .. somehow.

http://www.dsource.org/projects/ldc/ticket/384

Color me confused.
Comment 2 Don 2010-01-13 00:31:13 UTC
Removing 'patch' keyword since the patch is known to be incorrect.
Comment 3 Mathias LANG 2019-08-10 18:33:37 UTC
I don't think we can even make them constant. Not in a way that could be used in CTFE anyway (because there could be a linker script, or just PIC / PIE).
So going to close this as WONTFIX.