Bug 12809 – More strict nothrow check for try-finally statement

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-05-27T05:57:00Z
Last change time
2014-05-28T06:55:56Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2014-05-27T05:57:13Z
This is throwable function. void test_finally1() nothrow { try throw new Exception(""); // error finally {} } But if add assert(0); in finally block, the throwing exception should not cause nothrow violation. void test_finally2() nothrow { try throw new Exception(""); // should not be error finally assert(0); // unconditional halt } I found the issue when I tested the following snippet. void main() nothrow { scope(exit) assert(0); throw new Exception(""); }
Comment #1 by k.hara.pg — 2014-05-27T06:00:14Z
By fixing this issue, unreachable statement warning could be improved. void test1() { try assert(0); finally { int x = 1; // should be reported as unreachable } } void test2() { try {} finally assert(0); int x = 1; // should be reported as unreachable }
Comment #2 by k.hara.pg — 2014-05-27T06:38:38Z
Comment #3 by github-bugzilla — 2014-05-28T06:55:54Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/56017e5ae2c56f5bba2eeb6d5992a3b7a3920a50 fix Issue 12809 - More strict nothrow check for try-finally statement https://github.com/D-Programming-Language/dmd/commit/b72ed88d2394188ea2c08cfbe5b3d2fe8e88c3ef Merge pull request #3592 from 9rnsr/fix11542 Issue 11542 & 12809 - Improve blockExit calculation on try-catch-finally statement