On Sunday, 29 September 2013 at 17:35:33 UTC, andrea9940 wrote:
Thanks for the answer, I will use the aliases; however I just tried my code on codepad and surprising it worked without errors http://codepad.org/hp0YxIi7

I think there is a bug in there somewhere though:

//----
struct V{
    union {
        struct {
            float x = 0;
            float y = 0;
        }
        struct {
            float r;
            float g;
        }
    }
}

void main() {
    assert(V.init.x == 0 && V.init.y == 0); //Passes
    V v1 = V.init;
    assert(v1 is V.init); //Passes
    V v2 = V(); // OR simply use: V v2;
    assert(v2 is V.init); //Fails
}
//----

That just isn't right. "T.init" and "T()" is supposed to be equivalent (bar static opCall).

Also, I'm 99% confident that when initializing a union, the first member (in this case, the struct), is the one that gets initialized. *fully* initialized.

So my conclusion is that there is something wrong in the construction sequence/defintion, and that this bug is definitely valid.

Reply via email to