www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20797] New: Destructor marked as nothrow renders try-catch

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

          Issue ID: 20797
           Summary: Destructor marked as nothrow renders try-catch block
                    useless
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: razvan.nitu1305 gmail.com

struct K
{
    ~this() nothrow {}
}

void main()
{
    static class C
    {
        this(K, int) {}
    }

    static int foo(bool flag)
    {
        if (flag)
            throw new Exception("hello");
        return 1;
    }

    try
    {
        new C(K(), foo(true));
    }
    catch(Exception)
    {
    }
}

Result:

object.Exception test.d(18): hello

Expected result: code does not throw exception.

--
May 04