[Issue 1605] break in switch with goto breaks in ctfe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 24 04:21:21 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=1605


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |clugdbug at yahoo.com.au




--- Comment #1 from Don <clugdbug at yahoo.com.au>  2009-08-24 04:21:21 PDT ---
Actually this has nothing to do with switch or break. It only requires 'goto'
inside a while loop.
Reduced test case:

int Break()
{
    int i = 0;
    while (true) {   
        goto LABEL;
        LABEL:
        if (i!=0) return i;
        i = 27;
    }
    assert(i==27); // this passes, it did actually execute the loop.
    return 88; // unreachable
}

static assert(Break() == 27);
-----------
It's failing because the test for continuing to execute is wrong.
----
PATCH: interpret.c, Expression *WhileStatement::interpret(InterState *istate)

    if (e == EXP_BREAK_INTERPRET)
        return NULL;
-    if (e != EXP_CONTINUE_INTERPRET)
+    if (e && e != EXP_CONTINUE_INTERPRET)
        return e;
    }

    while (1)
    {
    e = condition->interpret(istate);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list