D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13669 - [CTFE] Destructor call on static array variable is not yet supported in CTFE
Summary: [CTFE] Destructor call on static array variable is not yet supported in CTFE
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: CTFE, pull
Depends on:
Blocks:
 
Reported: 2014-11-01 08:08 UTC by Kenji Hara
Modified: 2015-02-18 03:39 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2014-11-01 08:08:08 UTC
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())
Comment 2 github-bugzilla 2014-11-23 03:13:02 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6ee121df3eec74835b9d6e75b57af6f25bf009a9
fix Issue 13669 - [CTFE] Destructor call on static array variable is not yet supported in CTFE
Comment 3 github-bugzilla 2015-01-25 00:11:37 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/59a5fd49d1f03be8d0ac44abf03c109880f2aefb
Move issue 13669 test in runnable, and fix order of dtor calls
Comment 4 github-bugzilla 2015-02-18 03:39:58 UTC
Commits pushed to 2.067 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6ee121df3eec74835b9d6e75b57af6f25bf009a9
fix Issue 13669 - [CTFE] Destructor call on static array variable is not yet supported in CTFE

https://github.com/D-Programming-Language/dmd/commit/59a5fd49d1f03be8d0ac44abf03c109880f2aefb
Move issue 13669 test in runnable, and fix order of dtor calls