Bug 9745 – Allow non-thread local static variables to have their address taken in CTFE
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-18T04:59:00Z
Last change time
2015-06-09T05:11:51Z
Keywords
rejects-valid
Assigned to
nobody
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2013-03-18T04:59:41Z
Split off from bug 9744.
Applies to both shared and __gshared, (or any static variable in D1).
-------
shared int x1;
shared(int) * foo() { return & x1; }
shared int *p1 = & x1; // OK
shared int *p2 = foo(); // ERROR - & x1 is not valid in CTFE.
-------
Obviously, any attempt to dereference &x1 must fail.
Likewise, it must not be valid to take the address of a thread-local variable.
This is the largest remaining difference between constant-folding and CTFE.
Comment #1 by github-bugzilla — 2013-03-30T21:52:05Z