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

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

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

void throwAway()
    throw new MyException;

void cantthrow() nothrow
    catch(MyException me)
    catch(Exception e)

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:
------- You are receiving this mail because: -------

Reply via email to