[Issue 2380] static struct initializer accepted as non static initializer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 3 00:47:56 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2380





------- Comment #4 from samukha at voliacable.com  2008-10-03 02:47 -------
What's more surprising is that not all static initializers are allowed to
initialize non-statics:

int[] a = [1, 2, 3]; // ok. 
int[] b = [1 : 2, 3]; // fails. only static arrays can be initialized like this

Though it seems to be according to the specs, I don't see the reason why
initializers with indexes are special cased.

And this one may be considered a bug:
void foo()
{
  int[3] a = [ 1:2, 3 ]; // fails. static static arrays, only:
  static int[3] a = [ 1:2, 3 ]; // ok
}


-- 



More information about the Digitalmars-d-bugs mailing list