digitalmars.D.learn - DMD special exception "catch not allowed in finally block"
- Bradley Smith (44/44) Jun 23 2006 Why does DMD have this special exception for the finally block?
- Hasan Aljudy (2/6) Jun 25 2006 a bit OT, but, gdc is not a standard/reference compiler .. dmd is.
Why does DMD have this special exception for the finally block? The documentation states that "A FinallyStatement may not exit with a throw, goto, break, continue, or return; nor may it be entered with a goto.", but this is obviously not the case in the following code. The closeResources() method throws an exception which exits the finally statement. DMD simply is not allowing code which would handle the exception. void closeResources() { throw new Exception("from throwsException"); } void main() { // open resources try { // use resources } catch(Exception e) { // handle exception } finally { closeResources(); } } If this exception is really a part of the language, shouldn't the gdc compiler give the same behavior? The following code compiles with gdc but not dmd. void closeResources() { throw new Exception("from throwsException"); } void main() { // open resources try { // use resources } catch(Exception e) { // handle exception } finally { try { closeResources(); } catch (Exception e) { } } } Thanks, Bradley
Jun 23 2006
Bradley Smith wrote:If this exception is really a part of the language, shouldn't the gdc compiler give the same behavior? The following code compiles with gdc but not dmd.a bit OT, but, gdc is not a standard/reference compiler .. dmd is.
Jun 25 2006