Comment #0 by bearophile_hugs — 2011-05-14T04:37:23Z
I am not sure what's happening here (so no keywords), probably I am missing something. I am not even sure this is a bug, so it's better to ask here first. This crashes at runtime with no stack trace (DMD 2.053):
import std.stdio, std.bigint, std.container;
int foo() {
Array!BigInt bar;
bar ~= BigInt(2);
auto spam = heapify(bar);
spam.insert(BigInt(10));
spam.insert(BigInt(20));
return 1;
}
void main() {
writeln(foo());
}
If I replace the BigInts with ints:
import std.stdio, std.container;
int foo() {
Array!int bar;
bar ~= 2;
auto spam = heapify(bar);
spam.insert(10);
spam.insert(20);
return 1;
}
void main() {
writeln(foo());
}
I get:
...\dmd\src\phobos\std\container.d(2660): Error: this._store()[this._length()] is not an lvalue
Comment #1 by kennytm — 2011-05-14T08:07:43Z
I've got a stack trace for the first code in OS X.
[email protected](2366): Assertion failure
----------------
5 x 0x00016a8d onAssertError + 65
6 x 0x00020ace _d_assertm + 30
7 x 0x00044e8c void std.typecons.__assert(int) + 24
8 x 0x000041ea void std.typecons.__T10RefCountedTS3std9container30__T5ArrayTS3std6bigint6BigIntZ5Array7PayloadVE3std8typecons24RefCountedAutoInitialize0Z.RefCounted.__dtor() + 38
9 x 0x00004407 void std.container.Array!(std.bigint.BigInt).Array.__fieldDtor() + 11
10 x 0x00001f66 int x.foo() + 310
11 x 0x00001e27 _Dmain + 11
12 x 0x000211ef extern (C) int rt.dmain2.main(int, char**).void runMain() + 23
13 x 0x00020d99 extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 29
14 x 0x00021237 extern (C) int rt.dmain2.main(int, char**).void runAll() + 59
15 x 0x00020d99 extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 29
16 x 0x00020d33 main + 179
17 x 0x00001e11 start + 53
18 ??? 0x00000001 0x0 + 1
----------------
Comment #2 by zetetyck — 2011-11-16T07:07:07Z
*** Issue 6959 has been marked as a duplicate of this issue. ***
Comment #3 by safety0ff.bugz — 2014-03-11T13:18:41Z
This seems to have been fixed.
Comment #4 by andrei — 2014-03-19T15:23:21Z
Tested both, each prints 1 and returns normally. I assume some other fix took care of this.