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
}