www.fgks.org   »   [go: up one dir, main page]

Issue 13815 - Inconsistent goto jump behavior between compile-time and runtime
Summary: Inconsistent goto jump behavior between compile-time and runtime
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: CTFE, pull
Depends on:
Blocks:
 
Reported: 2014-12-04 07:40 UTC by Kenji Hara
Modified: 2021-04-20 00:03 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2014-12-04 07:40:23 UTC
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 Dlang Bot 2021-04-16 23:20:31 UTC
@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 Dlang Bot 2021-04-20 00:03:42 UTC
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