www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12809] New: More strict nothrow check for try-finally statement

https://issues.dlang.org/show_bug.cgi?id=12809

          Issue ID: 12809
           Summary: More strict nothrow check for try-finally statement
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: k.hara.pg gmail.com

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("");
}

--
May 26 2014