Bug 24749 – A clause consisting only of "throw" should be the unlikely path
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-09-07T20:21:54Z
Last change time
2024-09-14T06:20:02Z
Keywords
pull
Assigned to
No Owner
Creator
Walter Bright
Comments
Comment #0 by bugzilla — 2024-09-07T20:21:54Z
As suggested by Quirin Schroll.
int foo(int i)
{
if (i)
throw new Exception("hello");
return i;
}
should emit code this way:
int foo(int i)
{
if (!i)
return i;
throw new Exception("hello");
}
so the return statement is considered the most likely code execution path.
Comment #1 by dlang-bot — 2024-09-08T05:38:24Z
@WalterBright updated dlang/dmd pull request #16831 "fix Issue 24749 throw block moved to end of function" fixing this issue:
- fix Bugzilla Issue 24749 throw block moved to end of function
https://github.com/dlang/dmd/pull/16831
Comment #2 by dlang-bot — 2024-09-14T06:20:02Z
dlang/dmd pull request #16831 "fix Bugzilla Issue 24749 throw block moved to end of function" was merged into master:
- bc6c9895b3d568ad4c85a6e092ad04ced437bf9a by Walter Bright:
fix Bugzilla Issue 24749 throw block moved to end of function
https://github.com/dlang/dmd/pull/16831