www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9745] New: Allow non-thread local static variables to have their address taken in CTFE

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

           Summary: Allow non-thread local static variables to have their
                    address taken in CTFE
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au


--- Comment #0 from Don <clugdbug yahoo.com.au> 2013-03-18 04:59:41 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 18 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9745



--- Comment #1 from github-bugzilla puremagic.com 2013-03-30 21:52:05 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9745


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 30 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9745



--- Comment #2 from github-bugzilla puremagic.com 2013-04-18 11:23:12 PDT ---
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.

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