[Issue 13669] New: [CTFE] Destructor call on static array variable is not yet supported in CTFE
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Sat Nov  1 01:08:08 PDT 2014
    
    
  
https://issues.dlang.org/show_bug.cgi?id=13669
          Issue ID: 13669
           Summary: [CTFE] Destructor call on static array variable is not
                    yet supported in CTFE
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: CTFE
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: k.hara.pg at gmail.com
Following code should work, but doesn't.
bool test()
{
    string dtor;
    struct S
    {
        char x = 'x';
        ~this() { dtor ~= x; }
    }
    { S[2] a; }    // line 12
    assert(dtor == "xx");
    dtor = "";
    { S[2] a = [S('a'), S('b')]; }
    assert(dtor == "ab");
    return true;
}
static assert(test());
Currently the case outputs weird CTFE error.
test.d(12): Error: static variable typeid(S[2]) cannot be read at compile time
test.d(21):        called from here: test()
test.d(21):        while evaluating: static assert(test())
--
    
    
More information about the Digitalmars-d-bugs
mailing list