#3 Local exception handlers ignored with SOME user-declared exceptions.

1.0
open
nobody
None
2013-05-01
2013-05-01
Brian Drummond
No

User-declared exceptions can only be locally handled if they are locally declared. If they are declared in another package (even a local package), any raise will call the Last Chance handler and a local handler (if present) will be ignored.

This is believed to be related to
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53684

Standard exceptions such as Program_Error do not have this limitation : they may be locally handled, or handled by the Last Chance handler.

In either case, a local handler may not re-raise, as this is prohibited by pragma No_Exception_Propagation.

Workarounds:
Use standard exceptions, or
Declare exceptions locally (in the subprogram which will raise and handle them),or
Make the exceptions locally visible (via a Use clause on their package), or
Don't handle exceptions locally.

Fix may not be possible without a better resolution to the upstream bug.

Discussion

  • Brian Drummond
    Brian Drummond
    2013-05-01

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -10,6 +10,7 @@
     Workarounds: 
     Use standard exceptions, or
     Declare exceptions locally (in the subprogram which will raise and handle them),or
    +Make the exceptions locally visible (via a Use clause on their package), or
     Don't handle exceptions locally.
    
     Fix may not be possible without a better resolution to the upstream bug.