Comment #0 by bearophile_hugs — 2010-04-24T16:14:29Z
Using Phobos with dmd 2.043 this is wrong code, because it initialized the length field but doesn't actually extend the array.
I think this is a natural syntax that people will want to use, so I suggest to add this syntax, otherwise I think this will be a cause of bugs in programs.
So this is an enhancement request, but it's borderline with a bug report.
import std.bitmanip: BitArray;
void main() {
auto b = BitArray(10);
}
Comment #1 by andrej.mitrovich — 2014-04-24T18:35:50Z
I've tried implementing ctors which would get rid of the problem, but then found some failing code in a unittest:
-----
__gshared BitArray ba = { 10, &x };
-----
$ dmd test.d
> Error: struct BitArray has constructors, cannot use { initializers }, use BitArray( initializers ) instead
I'm not sure whether this is part of the API. Can we break this code?
Comment #2 by bearophile_hugs — 2014-04-24T18:45:31Z
(In reply to Andrej Mitrovic from comment #1)
> I'm not sure whether this is part of the API. Can we break this code?
I suggest to break that code. It's not something I'd like to see in D code.
Comment #3 by dlang-bugzilla — 2017-07-05T19:03:40Z
(In reply to bearophile_hugs from comment #2)
> I suggest to break that code. It's not something I'd like to see in D code.
Your example no longer compiles since https://github.com/dlang/phobos/pull/2854.