Thread overview
[Issue 5717] 1.067 regression: appending Unicode char to string broken
Mar 09, 2011
Sohgo Takeuchi
Mar 10, 2011
Don
Mar 10, 2011
Vladimir
Mar 10, 2011
Don
Mar 10, 2011
Don
Mar 11, 2011
Sohgo Takeuchi
Mar 11, 2011
Walter Bright
Mar 11, 2011
Vladimir
March 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5717


Sohgo Takeuchi <sohgo@sohgo.dyndns.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sohgo@sohgo.dyndns.org


--- Comment #1 from Sohgo Takeuchi <sohgo@sohgo.dyndns.org> 2011-03-09 21:35:00 JST ---
Same problem happens on FreeBSD 8.2 with DMD 1.067 too.
But the problem does not happen with DMD 1.066.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5717


Don <clugdbug@yahoo.com.au> changed:

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


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-03-10 01:14:55 PST ---
I think this is a foreach problem.
Probably triggered by the fix to bug 4389.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5717



--- Comment #3 from Vladimir <thecybershadow@gmail.com> 2011-03-10 01:17:37 PST ---
It doesn't look like a foreach problem. This fails too:

void main()
{
    string s, s2;
    s = "Привет";
    for (int i=0; i<s.length; i++)
        s2 ~= s[i];
    assert(s == s2);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5717



--- Comment #4 from Don <clugdbug@yahoo.com.au> 2011-03-10 04:26:27 PST ---
(In reply to comment #3)
> It doesn't look like a foreach problem. This fails too:

Hmm. You're right. And yet it works fine on D2.
It's inserting a call to _d_arrayappendcd, which means the append has been
changed into  char[] ~ dchar.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5717


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #5 from Don <clugdbug@yahoo.com.au> 2011-03-10 07:13:37 PST ---
It was indeed caused by the fix to bug 4389, which wasn't tight enough.
s~= c shouldn't turn c into a dchar, if both s and c are the same type. (ie,
char[]~=char should go through unaltered). That leaves wchar[] ~ char, which I
think is inevitably a mess if c is outside the ASCII range.

expression.c, line 8593. CatAssignExp::semantic()

   {   // Append array
        e2 = e2->castTo(sc, e1->type);
        type = e1->type;
        e = this;
    }
    else if (tb1->ty == Tarray &&
        (tb1next->ty == Tchar || tb1next->ty == Twchar) &&
+        e2->type->ty != tb1next->ty &&
        e2->implicitConvTo(Type::tdchar)
       )
    {   // Append dchar to char[] or wchar[]
        e2 = e2->castTo(sc, Type::tdchar);
        type = e1->type;
        e = this;

        /* Do not allow appending wchar to char[] because if wchar happens
         * to be a surrogate pair, nothing good can result.
         */

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 11, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5717



--- Comment #6 from Sohgo Takeuchi <sohgo@sohgo.dyndns.org> 2011-03-11 12:27:38 JST ---
(In reply to comment #5)

I've tried Don's patch, it works good in my environment.
That's great.
Thank you.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 11, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5717


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #7 from Walter Bright <bugzilla@digitalmars.com> 2011-03-11 03:07:29 PST ---
https://github.com/D-Programming-Language/dmd/commit/19e819f6b9e71bc18bc5496ff9638ae7ade3e5ad

https://github.com/D-Programming-Language/dmd/commit/610064e7f74ce8258bc4a3eafde52b7311b56da7

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 11, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5717



--- Comment #8 from Vladimir <thecybershadow@gmail.com> 2011-03-11 08:35:49 PST ---
Thanks - not sure what the second commit has to do with it, though.

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