www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10251] New: CTFE: Allow returning pointers to global static variables of known value

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10251

           Summary: CTFE: Allow returning pointers to global static
                    variables of known value
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au



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'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 03 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10251




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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 04 2013