[Issue 2093] string concatenation modifies original

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 21 18:40:33 PST 2008


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


smjg at iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code




------- Comment #3 from smjg at iname.com  2008-11-21 20:40 -------
I think I've finally managed to figure out what was going on.

----------
import std.stdio;

void main() {
    string s1, s2;

    s1 ~= "hello";
    s2 = s1;

    writefln(s1);
    writefln(s2);

    s1.length = 0;
    s1 ~= "Hi";

    writefln(s1);
    writefln(s2);
}
----------
hello
hello
Hi
Hillo
----------

This is the kind of testcase we like here.  Walter is more likely to fix a bug
if you make life easier for him by supplying something on which the cause can
easily be seen.


-- 



More information about the Digitalmars-d-bugs mailing list