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

           Summary: [CTFE] foreach ref element doesn't work well at
                    compile time.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: zan77...@nifty.com


--- Comment #0 from SHOO <zan77...@nifty.com> 2012-10-07 01:18:56 PDT ---
This code doesn't work well:
--------------------------------------
import std.stdio;

void foo(ref string[] data)
{
    foreach (ref e; data)
    {
        e = e ~ "!";
    }
}
string[] bar(string[] data)
{
    foo(data);
    return data;
}
void main()
{
    enum data = ["a", "bcde", "abcde"];
    enum resCt = bar(data);
    auto resRt = bar(data);
    writeln(resCt); // NG: ["a", "bcde", "abcde"]
    writeln(resRt); // OK: ["a!", "bcde!", "abcde!"]
    assert(resCt == resRt); // NG
}
-------------------------------------

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

Reply via email to