www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18279] New: rt.util.utf does not properly reserve buffer in


          Issue ID: 18279
           Summary: rt.util.utf does not properly reserve buffer in
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: trivial
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

The offending pattern:
    wchar[] r;
    size_t slen = s.length;
    r.length = slen;
    r.length = 0;
    // ... followed by code that appends to r with ~=

The apparent intention is to preallocate the buffer but this idiom doesn't work
as pointed out by Dmitry Olshansky: "On append the slice is not the tail so it
will reallocate."

Jan 22 2018