Bug 5663 – std.array.Appender.put bug

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-02-27T21:57:00Z
Last change time
2011-06-20T19:20:53Z
Keywords
patch
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2011-02-27T21:57:25Z
Following test fails. Appender.put treats const(T)[]/immutable(T)[] argument as general input range. unittest { alias .std.array.Appender!(char[]) StdApp; { StdApp app; app.put("\xE3"); //thrown "Invalid UTF-8 sequence" assert(app.data == "\xE3"); } { StdApp app; app.put(cast(const(char)[])"\xE3"); //thrown "Invalid UTF-8 sequence" assert(app.data == "\xE3"); } { StdApp app; app.put(cast(char[])"\xE3"); //char[] -> ok assert(app.data == "\xE3"); } }
Comment #1 by k.hara.pg — 2011-02-27T22:02:45Z
Following patch will fix this bug. std/array.d | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/std/array.d b/std/array.d index c0f466c..e0c64f0 100644 --- a/std/array.d +++ b/std/array.d @@ -1196,7 +1196,9 @@ Appends an entire range to the managed array. // note, we disable this branch for appending one type of char to // another because we can't trust the length portion. static if (!(isSomeChar!T && isSomeChar!(ElementType!Range) && - !is(Range == Unqual!(T)[])) && + !is(Range == Unqual!T[]) && + !is(Range == const(T)[]) && + !is(Range == immutable(T)[])) && is(typeof(items.length) == size_t)) { // optimization -- if this type is something other than a string,
Comment #2 by k.hara.pg — 2011-06-20T19:20:53Z