www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5722] New: Regression(2.052): Appending code-unit from multi-unit code-point at compile-time gives wrong result.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5722

           Summary: Regression(2.052): Appending code-unit from multi-unit
                    code-point at compile-time gives wrong result.
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: cbkbbejeap mailinator.com



17:46:13 PST ---
static assert( (""~"\©"[0]).length == 1 );

That passes on 2.051, but fails on 2.052 with "static assert (2u == 1u) is
false"

This is likely *not* related to issue 5717, since that test case works in
2.052.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 08 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5722




17:50:42 PST ---
Rather, this is *not the same as* issue 5717. They may be related.

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


Don <clugdbug yahoo.com.au> changed:

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



Like bug 5717, this was caused by the fix to bug 4389 (char[]~dchar and
wchar[]~dchar *never* worked).
The problem is in constfold.c, Cat(). 

It erroneously assumes that all concatenation is equivalent to string ~ dchar.
But this isn't true for char[]~char, wchar[]~wchar, (this happens during
constant-folding optimization, which is how it manifests in the test case). In
such cases the dchar encoding should not occur - it should just give an
encoding length of 1, and do a simple memcpy.

It applies to everything of the form (e2->op == TOKint64) in that function.

(1)        size_t len = es1->len + utf_codeLength(sz, v);
        s = mem.malloc((len + 1) * sz);
        memcpy(s, es1->string, es1->len * sz);
(2)        utf_encode(sz, (unsigned char *)s + , v);

Lines (1) and (2) are valid for hetero concatenation, but when both types are
the same the lines should be:

(1)     size_t len = es1->len + 1;

(2)     memcpy((unsigned char *)s + (sz * es1->len), &v, sz);

This should definitely be factored out into a helper function -- it's far too
repetitive already.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 11 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5722


Walter Bright <bugzilla digitalmars.com> changed:

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



14:47:29 PDT ---
Patch by Don Clugston:

https://github.com/D-Programming-Language/dmd/commit/41617e9ade97187467383a12314267cb0cd5df49

https://github.com/D-Programming-Language/dmd/commit/49e7f2a80ab2bdc042d33d63c4332767a0bf1911

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