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: nob...@puremagic.com
          Reporter: razvan.nitu1...@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.

--

Reply via email to