www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11427] New: anonymous unions break structs in safe code

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

           Summary: anonymous unions break structs in  safe code
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: r.sagitario gmx.de


--- Comment #0 from Rainer Schuetze <r.sagitario gmx.de> 2013-11-03 01:52:10
PST ---
Compile this code

///////////////////
struct S
{
    union
    {
        ubyte a;
        int x;
    }
    void[] arr;
}

int foo()  safe
{
    S s1 = S();
    S s2;
    return 0;
}
////////////////////

with "dmd -c test.d" fails with

test.d(14): Error: variable test.foo.s2 unions containing pointers are not
allowed in  safe functions

Please note that the first variable s1 is ok!

This is also triggered in std.format with this code:
import std.format;
import std.array;

void foo()
{
    FormatSpec!char spec = FormatSpec!char();
    auto s = appender!string;
    formattedWrite(s, "%s", "hello");
}

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



--- Comment #1 from Rainer Schuetze <r.sagitario gmx.de> 2013-11-03 01:32:10
PST ---
Hmmm, something wrong with bugzilla? My comment replaced the description, and
the initial description is now moved into the first comment.

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