www.digitalmars.com         C & C++   DMDScript  

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

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

          Issue ID: 14023
           Summary: [CTFE] postblits/destructors not called on static
                    array index 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++; }
    }

    S[3] sa;
    S[3][] arr = [[S(), S(), S()]];
    assert(cpctor == 0 && dtor == 0);
    arr[0] = sa;
    assert(cpctor == 3 && dtor == 3);

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

--
Jan 21 2015