www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14022] New: [CTFE] postblits/destructors not called on static

https://issues.dlang.org/show_bug.cgi?id=14022

          Issue ID: 14022
           Summary: [CTFE] postblits/destructors not called on static
                    array field assignment
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: CTFE
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: k.hara.pg gmail.com

int test()
{
    int cpctor, dtor;

    struct S
    {
        this(this) { cpctor++; }
        ~this() { dtor++; }
    }
    struct T
    {
        S[3] member;
    }

    S[3] sa;
    T t;
    assert(cpctor == 0 && dtor == 0);
    t.member = sa;
    assert(cpctor == 3 && dtor == 3);

    return 1;
}
//static assert(test());   // ctfe -> fails
void main()
{
    test();  // runtime -> ok
}

--
Jan 21 2015