BinaryHeap crashes upon insertion if heapified with an array of length 1?

TheGag96 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 8 17:36:00 PDT 2017


I'm trying to use a binary heap initialized with one element. 
However, this always seems to cause a range violation for some 
reason. This small example will do it:

import std.stdio, std.container;

void main() {
   auto pq = heapify([5]);
   pq.insert(8);
}

...And it produces this error: https://pastebin.com/dyLNRz2W

Oddly enough, if I heapify an array with any other length than 1, 
I can insert as much as I want (that includes an empty array!). 
Is this a bug in Phobos or some odd expected behavior? Thanks 
guys!


More information about the Digitalmars-d-learn mailing list