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

           Summary: struct with union considered unsafe only in second
                    struct literal
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Rainer Schuetze <[email protected]> 2013-11-30 01:44:46 
PST ---
Compiling:

///////////////
struct S
{
    union
    {
        int[] a;
        int[] b;
    }
}

void foo()()
{
    S s1 = S();
    S s2 = S(); // line 19: compiles without this line
}

void main() @safe
{
    foo();
}
///////////////

yields:

test2.d(19): Error: safe function 'D main' cannot call system function
'test2.foo!().foo'

Please note, that the error does not happen with only s1 being declared.

std.regex makes use of the buggy behaviour, otherwise std.regex.replace would
not infer as @safe because struct Captures contains a similar union.

Note: https://github.com/D-Programming-Language/dmd/pull/2480 contains a fix
for this, but causes the unittests of std.regex to fail.

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

Reply via email to