[Issue 11427] anonymous unions break structs in @safe code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 13 07:35:25 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11427


Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from Rainer Schuetze <r.sagitario at 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");
}

--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2013-11-13 07:35:24 PST ---
https://github.com/D-Programming-Language/dmd/pull/2757

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


More information about the Digitalmars-d-bugs mailing list