Thread overview
[Issue 4969] New: nothrow check can't handle multiple catches
Oct 02, 2010
Jonathan M Davis
Jun 19, 2011
kennytm@gmail.com
Jun 20, 2011
Walter Bright
October 02, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4969

           Summary: nothrow check can't handle multiple catches
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: jmdavisProg@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg@gmx.com> 2010-10-01 20:55:33 PDT ---
This code should compile:

class MyException : Exception
{
    this()
    {
        super("An exception!");
    }
}

void throwAway()
{
    throw new MyException;
}

void cantthrow() nothrow
{
    try
        throwAway();
    catch(MyException me)
        assert(0);
    catch(Exception e)
        assert(0);
}

void main()
{
}


It doesn't. Instead, you get this error:

d.d(14): Error: function d.cantthrow 'cantthrow' is nothrow yet may throw


If you remove catch(MyException e) and its body, then the program compiles. Given that the catch block that catches MyException cannot throw an exception of its own and that the catch block following it catches Exception (and therefore will catch all exceptions) and cannot throw an exception, the compiler should be able to clearly determine that no exception can escape cantthrow, but apparently, it can't.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4969


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |kennytm@gmail.com


--- Comment #1 from kennytm@gmail.com 2011-06-19 09:34:14 PDT ---
DMD pull #145.

https://github.com/D-Programming-Language/dmd/pull/145

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4969


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-06-20 16:34:00 PDT ---
https://github.com/D-Programming-Language/dmd/commit/1809f7b5baaf6bb34879f19f5ba75af5f997c920

https://github.com/D-Programming-Language/dmd/commit/d4e602c2e2d2516f2958a762073ea7f6c98914f6

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------