Comment #0 by bearophile_hugs — 2013-08-20T07:31:25Z
I don't know if this is a regression. Here "words.txt" is just a file of words separated by a newline:
import std.stdio: File;
import std.algorithm: map;
import std.typecons: tuple;
import std.array: array;
void main() {
File("words.txt")
.byLine
.map!(line => tuple(line))
.array
;
}
If I compile with -g it gives at run-time, dmd 2.064alpha:
[email protected](1927): Assertion failure
----------------
0x00424903 in onAssertError
0x0040ED86 in pure nothrow @safe void std.typecons.Tuple!(char[]).Tuple.opAssign!(std.typecons.Tuple!(char[]).Tuple).opAssign(std.typecons.Tuple!(char[]).Tuple) at ...\dmd2\src\phobos\std\typecons.d(525)
0x0040F5A4 in pure nothrow @safe void std.array.Appender!(std.typecons.Tuple!(char[]).Tuple[]).Appender.put!(std.typecons.Tuple!(char[]).Tuple).put(std.typecons.Tuple!(char[]).Tuple) at ...\dmd2\src\phobos\std\array.d(2347)
0x0040EE72 in D3std5array116__T5arrayTS6test5b4main80__T9MapResultS226test5b4main9__lambda2TS3std5stdio4File1F8E0F5CC6B0162C488BCADE9A33A8B01 at ...\dmd2\src\phobos\std\array.d(70)
0x00402087 in _Dmain at ...\test5b.d(7)
0x0041C580 in extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void runMain()
0x0041C610 in extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void runAll()
0x0041BEED in _d_run_main
0x004084D0 in main
0x00432825 in mainCRTStartup
0x7691D2E9 in BaseThreadInitThunk
0x76FB1603 in RtlInitializeExceptionChain
0x76FB15D6 in RtlInitializeExceptionChain
----------------
If inside the main I replace "array" with "writeln" the program works correctly.
Comment #1 by monarchdodra — 2013-08-20T09:06:00Z
Kind of like #10690: Combination bug
Array calls appender.
appender calls opAssign on un-initilized memory (which is wrong: It should call emplace... but emplace is broken, so that wouldn't change much anyways)
In any case, once inside Tuple.opAssign, the implementation will *swap* (correctly).
Unfortunatly, since "this" is not initialized, an assert will trigger in "swap", as the string "points" to the other object.
There are many steps involved for a "full" recovery, but I think that removing the "pointsTo" assertion in "swap" is the first step:
http://d.puremagic.com/issues/show_bug.cgi?id=9975#c14https://github.com/D-Programming-Language/phobos/pull/1390
(In reply to comment #1)
> Kind of like #10690: Combination bug
>
> Array calls appender.
>
> appender calls opAssign on un-initilized memory (which is wrong: It should call
> emplace... but emplace is broken, so that wouldn't change much anyways)
>
> In any case, once inside Tuple.opAssign, the implementation will *swap*
> (correctly).
>
> Unfortunatly, since "this" is not initialized, an assert will trigger in
> "swap", as the string "points" to the other object.
>
> There are many steps involved for a "full" recovery, but I think that removing
> the "pointsTo" assertion in "swap" is the first step:
> http://d.puremagic.com/issues/show_bug.cgi?id=9975#c14
> https://github.com/D-Programming-Language/phobos/pull/1390
Still same symptoms as 10690: Not fixed because appender calls opAssign.
Comment #5 by monarchdodra — 2013-08-28T04:29:56Z
(In reply to comment #4)
> (In reply to comment #1)
> > Kind of like #10690: Combination bug
> >
> > Array calls appender.
> >
> > appender calls opAssign on un-initilized memory (which is wrong: It should call
> > emplace... but emplace is broken, so that wouldn't change much anyways)
> >
> > In any case, once inside Tuple.opAssign, the implementation will *swap*
> > (correctly).
> >
> > Unfortunatly, since "this" is not initialized, an assert will trigger in
> > "swap", as the string "points" to the other object.
> >
> > There are many steps involved for a "full" recovery, but I think that removing
> > the "pointsTo" assertion in "swap" is the first step:
> > http://d.puremagic.com/issues/show_bug.cgi?id=9975#c14
> > https://github.com/D-Programming-Language/phobos/pull/1390
>
> Still same symptoms as 10690: Not fixed because appender calls opAssign.
https://github.com/D-Programming-Language/phobos/pull/1529
Comment #6 by verylonglogin.reg — 2013-09-30T07:19:59Z
This is a clear dup caused by same appender issue (onAssign call on garbage).
*** This issue has been marked as a duplicate of issue 10690 ***