Bug 10895 – incorrect std.array.join behavior with array of string-like class using alias this

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-25T23:34:00Z
Last change time
2015-10-04T18:20:44Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
thelastmammoth

Comments

Comment #0 by thelastmammoth — 2013-08-25T23:34:43Z
(posted under 'alias this bug?' in D newsgroup but didn't get any answer) is this a bug? the call to join invalidates the "name" field of A: ---- import std.array; import std.stdio; class A{ string name; this(string name){this.name=name;} alias name this; ~this(){ writeln("deleting"); } } void main(){ auto a=[new A(`foo`)]; assert(a[0].length); writeln("1"); auto temp=a.join(" "); writeln("2"); assert(!a[0].length); //a[0] is now empty! }
Comment #1 by k.hara.pg — 2015-09-03T08:56:56Z
The bug was in std.array.join. The element of RoR had been consumed incorrectly while constructing the result. Fortunately the bug has been fixed in: https://github.com/D-Programming-Language/phobos/pull/2746 And does not happen since 2.067. PR to add unittest into Phobos: https://github.com/D-Programming-Language/phobos/pull/3628
Comment #2 by github-bugzilla — 2015-09-03T09:39:05Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/8e11f0ebe23d2fab92bf979595729a5b2038055e fix Issue 10895 - incorrect std.array.join behavior with array of string-like class using alias this https://github.com/D-Programming-Language/phobos/commit/13d9dbdabfb6d9e1ce2958a09982473408853b9e Merge pull request #3628 from 9rnsr/fix10895 Issue 10895 - incorrect std.array.join behavior with array of string-like class using alias this
Comment #3 by github-bugzilla — 2015-10-04T18:20:44Z
Commits pushed to stable at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/8e11f0ebe23d2fab92bf979595729a5b2038055e fix Issue 10895 - incorrect std.array.join behavior with array of string-like class using alias this https://github.com/D-Programming-Language/phobos/commit/13d9dbdabfb6d9e1ce2958a09982473408853b9e Merge pull request #3628 from 9rnsr/fix10895