Bug 10251 – CTFE: Allow returning pointers to global static variables of known value

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-03T02:42:00Z
Last change time
2015-06-09T05:12:00Z
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2013-06-03T02:42:28Z
This is a bug. It works if the variable doesn't have a known value! It also works in optimize(WANTinterpret) but not CTFE, ---- static const int glob10251 = 7; const (int) * bug10251() { return &glob10251; } static a10251 = &glob10251; // OK static b10251 = bug10251(); // Fails --- bug.d(10): Error: cannot use non-constant CTFE pointer in an initializer 'glob10251'
Comment #1 by github-bugzilla — 2013-06-04T18:08:59Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c991a71391c0667e9e7f95cec746897c3092d002 Fix bug 10251 CTFE: Allow returning pointers to global statics of known value Don't expand pointers to global variables. They should stay as a SymOffExp, even if their value is known.