www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9744] New: shared and __gshared variables can have their address taken at compile time

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

           Summary: shared and __gshared variables can have their address
                    taken at compile time
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au


--- Comment #0 from Don <clugdbug yahoo.com.au> 2013-03-18 02:58:09 PDT ---
Taking the address of a static variable is rejected, but not a __gshared
variable:

---
__gshared int x1;
static int x2;
static void *q1 = &x1;    // Compiles
static void *q2 = &x2;    // Rejected
---

bug.d(4): Error: non-constant expression & x2


This doesn't apply in CTFE, only in constant folding.

There is a unittest in bitmanip which relies on this bug.

-- 
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=9744



--- Comment #1 from Don <clugdbug yahoo.com.au> 2013-03-18 03:09:01 PDT ---
Or perhaps the correct behaviour would be to allow shared and __gshared to have
their address taken in all cases (including CTFE), and to generate an error
"cannot take the address of a thread-local variable at compile time" for static
variables.

Currently, the error is generated in the glue layer, which is wrong.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|accepts-invalid             |diagnostic
            Summary|shared and __gshared        |Poor error message taking
                   |variables can have their    |address of thread-local
                   |address taken at compile    |variable at compile time
                   |time                        |


--- Comment #2 from Don <clugdbug yahoo.com.au> 2013-03-18 03:54:33 PDT ---
I'm splitting this bug report into two parts. This one becomes a diagnostic
error message for the thread-local case.
The second will be a CTFE enhancement, to allow taking the address of static
variables inside CTFE.

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



--- Comment #3 from github-bugzilla puremagic.com 2013-03-30 21:51:56 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/7aa4ef0974cc9ffe2267883c2e98bf00d5285cba
Fix issue 9744 Poor error message taking address of thread-local variable at
compile time

Move the error message from the glue layer, into the interpreter.
Also fix an incorrect entry point into the glue layer.

-- 
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=9744


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