static enum member of incomplete type, valid or not?

TommiT tommitissari at hotmail.com
Wed Mar 27 05:01:37 PDT 2013


I'd like to get a definite answer to whether the following code 
is valid or not:

struct S
{
     int v = 42;
     this(int val) { v = val + 1; }
     enum s = S(4);
}

void main()
{
     static assert(S.s.v == 5);
}

There's a bug report about it:
http://d.puremagic.com/issues/show_bug.cgi?id=9397

...but according to some of the comments there, the code isn't 
valid anyway, so it's not a bug.

This question is parallel to C++, where the following is 
currently invalid:

struct S
{
     int v;
     static constexpr S s = S{4};
};

...but there's been a proposal to change the wording of the 
standard that would make the code valid.


More information about the Digitalmars-d-learn mailing list