http://d.puremagic.com/issues/show_bug.cgi?id=5907

           Summary: CTFE: Ref assignments are noop at compile time
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: andrej.mitrov...@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrov...@gmail.com> 2011-04-28 
17:05:20 PDT ---
auto ok()
{
    int[2] result;
    foreach (index, ref sample; result)
    {
        result[index] = 1;
    }
    return result;    
}

auto fail()
{
    int[2] result;
    foreach (index, ref sample; result)
    {
        sample = 1;
    }
    return result;
}

float[2] ctfe_ok   = ok();
float[2] ctfe_fail = fail();

void main()
{
    assert(ok == [1, 1]);       // ok
    assert(fail == [1, 1]);     // ok

    assert(ctfe_ok == [1, 1]);
    assert(ctfe_fail == [1, 1]);    // throws
}

Unfortunately they fail silently and then you have bugs in your code. I'm not
sure but maybe this bug was reported already? (or a fix is scheduled for the
next release?) 

I couldn't be sure so I'm reporting it just in case.

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

Reply via email to