www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8773] New: [CTFE] foreach ref element doesn't work well at compile time.

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: zan77137 nifty.com



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: -------
Oct 07 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8773


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au



Duplicate of bug 7658?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 08 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8773


SHOO <zan77137 nifty.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE



Hm... By all appearance it looks like it.

*** This issue has been marked as a duplicate of issue 7658 ***

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