[Issue 13815] New: Inconsistent goto jump behavior between compile-time and runtime
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Dec 3 23:40:23 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13815
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 at puremagic.com
Reporter: k.hara.pg at gmail.com
Following code behaves differently in compile-time and runtime.
bool f()
{
goto L;
try
{
L: // line 7
throw new Exception(""); // line 8
}
catch (Exception e)
{
return true;
}
return false;
}
static assert(f());
void main()
{
f();
}
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
--
More information about the Digitalmars-d-bugs
mailing list