Bug 13815 – Inconsistent goto jump behavior between compile-time and runtime
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-04T07:40:23Z
Last change time
2021-04-20T00:03:42Z
Keywords
CTFE, pull
Assigned to
No Owner
Creator
Kenji Hara
Comments
Comment #0 by k.hara.pg — 2014-12-04T07:40:23Z
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
Comment #1 by dlang-bot — 2021-04-16T23:20:31Z
@MoonlightSentinel updated dlang/dmd pull request #12439 "Use correct scope during statementSemantic on try-block" fixing this issue:
- Fix 13815 - Use correct scope during statementSemantic on try-block
`sc2` was created but never used (probably a typo).
While running the code doesn't cause errors in CTFE it triggers an
assert in backend.
https://github.com/dlang/dmd/pull/12439
Comment #2 by dlang-bot — 2021-04-20T00:03:42Z
dlang/dmd pull request #12439 "Fix 13815 - Use correct scope during statementSemantic on try-block" was merged into master:
- e7eb6efffa1a3c6aa5739ccc5196be4beab7ec15 by MoonlightSentinel:
Fix 13815 - Use correct scope during statementSemantic on try-block
`sc2` was created but never used (probably a typo).
While running the code doesn't cause errors in CTFE it triggers an
assert in backend.
https://github.com/dlang/dmd/pull/12439