D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5998 - Problem with heapified Array!BigInt
Summary: Problem with heapified Array!BigInt
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
: 6959 (view as issue list)
Depends on:
Blocks:
 
Reported: 2011-05-14 04:37 UTC by bearophile_hugs
Modified: 2014-03-19 15:23 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2011-05-14 04:37:23 UTC
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 kennytm 2011-05-14 08:07:43 UTC
I've got a stack trace for the first code in OS X.


core.exception.AssertError@std.typecons(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 zetetyck 2011-11-16 07:07:07 UTC
*** Issue 6959 has been marked as a duplicate of this issue. ***
Comment 3 safety0ff.bugz 2014-03-11 13:18:41 UTC
This seems to have been fixed.
Comment 4 Andrei Alexandrescu 2014-03-19 15:23:21 UTC
Tested both, each prints 1 and returns normally. I assume some other fix took care of this.