'static' keyword for positional array initialization

Ali Cehreli acehreli at yahoo.com
Wed Aug 12 09:24:03 PDT 2009


Don Wrote:

> > void main()
> > {
> >     int[2] static_0 = [ 1, 1 ];
> >     int[2] static_1 = [ 1:1 ];
> > }
> > 
> > dmd: init.c:431: virtual Expression* ArrayInitializer::toExpression(): Assertion `j < edim' failed.
> 
> I've added this to Bugzilla as bug 3246. With a patch <g>.

Thank you for the quick fix! :)

But I still can't parse the answer that I am looking for. :)

The compiler should pass the assertion, ok, but what should itdo after that?

a) Reject both
b) Accept both
c) Accept static_0 but reject static_1

Option c would contradict with the documentattion though:

  http://digitalmars.com/d/2.0/arrays.html

It says: "Static arrays are distinguished by having a length fixed at compile time."

Also says: "Static Initialization of Static Arrays: Static initalizations are supplied by a list of array element values enclosed in [ ]. The values can be optionally preceded by an index and a :."

Those definitions make me think that both static_0 and static_1 should both be accepted.

Thank you,
Ali



More information about the Digitalmars-d-learn mailing list