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
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/aa0ec787714dff32a83d2666eaf3e2e07454e254 Fix issue 9745 Allow &staticvar in CTFE Use SymOffExp for non-dereferenceable pointers to static variables. It's already supported in the const-folding code, now support it in CTFE as well. This commit adds full support for pointer arithmetic.
Comment #2 by github-bugzilla — 2013-04-18T11:23:12Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/baaa2375b19f5689046bbc6334efcaca538fb637 Fix issue 9745 Allow &staticvar in CTFE Use SymOffExp for non-dereferenceable pointers to static variables. It's already supported in the const-folding code, now support it in CTFE as well. This commit adds full support for pointer arithmetic.