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

           Summary: Passing string literal by ref changes its bounds
                    forever
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: verylonglogin....@gmail.com


--- Comment #0 from Denis <verylonglogin....@gmail.com> 2011-12-24 15:41:24 MSK 
---
---
import std.stdio;

void f(ref string s) {
    writeln(s);
    if(s.length)
        --s.length;
    else
        s = "def";
}

void g1() { f("abc"); }
void g2() { f("abc"); }

void main()
{
    g1();     // prints "abc"
    g2();     // prints "ab"
    f("abc"); // prints "a"
    f("abc"); // prints ""
    f("abc"); // prints "def"
}
---

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

Reply via email to