D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6933 - Segfault(declaration.c) using struct with destructor in CTFE
Summary: Segfault(declaration.c) using struct with destructor in CTFE
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-11-11 17:32 UTC by Don
Modified: 2015-06-09 05:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2011-11-11 17:32:08 UTC
struct Bug6933 {
    int x = 3;
    ~this()     {  }
}

int test6933() {
    Bug6933 q;
    return 3;
}

static assert(test6933());

It's because interpret.c, getVarExp calls StructLiteralExp::semantic with NULL scope. semantic sees there's a destructor, and converts it into:
(Bug7973 __tmp = Bug6973(), __tmp). This crashes because __tmp is a variable with no scope. I don't understand why it does that transformation, it seems to me to be in the wrong place.