www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13815] New: Inconsistent goto jump behavior between


          Issue ID: 13815
           Summary: Inconsistent goto jump behavior between compile-time
                    and runtime
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: CTFE
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: k.hara.pg gmail.com

Following code behaves differently in compile-time and runtime.

bool f()
    goto L;
L:                                  // line 7
        throw new Exception("");    // line 8
    catch (Exception e)
        return true;
    return false;
static assert(f());

void main()

If you compile the code, CTFEing f() will raise compile-time errors:

test.d(8): Error: Uncaught CTFE exception object.Exception("")
test.d(16):        called from here: f()
test.d(16):        while evaluating: static assert(f())

But, if you mask the static assert, codegen for the function will report a
glue-layer error:

test.d(7): Error: cannot goto into try block

Dec 03 2014