Don <> changed:

           What    |Removed                     |Added
           Keywords|                            |patch
                 CC|                            |

--- Comment #1 from Don <> 2010-03-24 12:02:25 PDT ---
Most of the issues described here are duplicates of bug 1330, or bug 3801.
The segfault is the only new bug here. Here's a reduced test case:

struct Segfault3984 {
    int a;
    this(int x){
      a = x;

void bug3984(){
    static assert(Segfault3984(3).a == 3);

Root cause:
Struct constructors can result in a situation where a CTFE variable is created
outside of a CTFE function. They need a context to put the variable into.
Effectively, the comma expression acts a very simple function.


Interpret.c line 2641

Expression *CommaExp::interpret(InterState *istate)
#if LOG
    printf("CommaExp::interpret() %s\n", toChars());
    // If the comma returns a temporary variable, it needs to be an lvalue
    // (this is particularly important for struct constructors)
    if (e1->op == TOKdeclaration && e2->op == TOKvar 
       && ((DeclarationExp *)e1)->declaration == ((VarExp*)e2)->var)
+    // If there's no context for the variable to be created in,
+    // we need to create one now.
+    InterState istateComma;
+    if (!istate)
+        istate = &istateComma;

    VarExp* ve = (VarExp *)e2;
    VarDeclaration *v = ve->var->isVarDeclaration();
    if (!v->init && !v->value)
        v->value = v->type->defaultInitLiteral();

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to