January 30, 2015 BitArray crash | ||||
---|---|---|---|---|
| ||||
Hi, I'm trying to use BitArray instead of rolling my own. But how does one use it? I tried: import std.bitmanip : BitArray; int main() { BitArray b; b[2] = true; return 0; } $ gdc l.d $ gdb a.out (gdb) r Program received signal SIGSEGV, Segmentation fault. 0x0000000000438f88 in std.bitmanip.BitArray.opIndexAssign() (this=..., b=true, i=2) at ../../../../src/libphobos/src/std/bitmanip.d:604 Huh? (gdc-4.8 (Ubuntu 4.8.2-19ubuntu1) 4.8.2) I think I have to set "length" first. At least an example at the docs of bitsSet() halfway down the page does it... |
January 31, 2015 Re: BitArray crash | ||||
---|---|---|---|---|
| ||||
Posted in reply to Danny |
> I think I have to set "length" first.
Yes.
Declaring
BitArray b;
is like declaring
int[] a; // ={.length = 0, . ptr = null}
you get the segfault for invalid dereference.
|
Copyright © 1999-2021 by the D Language Foundation