comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Drummond <brian@shapes.demon.co.uk>
Subject: Re: Extended Exceptions and other tweaks.
Date: Sun, 5 May 2013 12:41:41 +0000 (UTC)
Date: 2013-05-05T12:41:41+00:00	[thread overview]
Message-ID: <km5k24$3v9$1@dont-email.me> (raw)
In-Reply-To: klse6e$o9o$1@munin.nbi.dk

On Wed, 01 May 2013 20:06:20 -0500, Randy Brukardt wrote:

> "Brian Drummond" <brian@shapes.demon.co.uk> wrote in message
> news:kls8v6$70i$1@dont-email.me...
> ...
>> So the following ,
>>
>> raise Timer_A.oops; -- last chance handler!
>> and use Timer_A;
>> raise oops; -- can be locally handled
>>
>> end up in different exception handlers!
>>
>> I'm not clear on whether this is expected behaviour...
> 
> It's certainly not Ada behavior. 

I have failed to reproduce that one with the native compiler...
However I did find this interesting specimen: (source below)

The compiler apparently agrees with my understanding of 
"pragma Restrictions (No_Exception_Propagation)" which is:
Immediately local exception handler is allowed;
Last chance handler is allowed; (and raising another exception in "doit2" 
will indeed reach the Last chance handler)
Anything in between is (a) not permitted and (b) will not run...

gnatmake -gnatwa -gnatw.x test_eh.adb
gcc -c -gnatwa -gnatw.x test_eh.adb
test_eh.adb:16:07: warning: pragma Restrictions 
(No_Exception_Propagation) in effect
test_eh.adb:16:07: warning: execution may raise unhandled exception
test_eh.adb:27:04: warning: pragma Restrictions 
(No_Exception_Propagation) in effect
test_eh.adb:27:04: warning: this handler can never be entered, and has 
been removed

but the resulting executable does not...

./test_eh
Main program start
Local handler : oops!
Second try
No_Exception_Propagation: this cannot happen...

Now is there a reasonable explanation that I have missed, or is this 
worth reporting as a compiler bug?

- Brian



Compiler versions:
FSF Gnat 4.6.3, 4.7.2
GNATMAKE GPL 2011 (20110419)

Source :
--------------------------------------------------------------------
pragma Restrictions (No_Exception_Propagation);

with Ada.Text_IO;  use Ada.Text_IO;

procedure Test_EH is

   Oops : exception;

   procedure doit is begin
      raise Oops;
   exception
      when Oops => Ada.Text_IO.Put_Line("Local handler : oops!");
   end doit;

   procedure doit2 is begin
      raise Oops;   -- line 16
      -- raise Program_Error;
   end doit2;
 
begin
   Ada.Text_IO.Put_Line("Main program start");
   doit;
   Ada.Text_IO.Put_Line("Second try");
   doit2;
   Ada.Text_IO.Put_Line("Main program done");
exception
   when Oops => Ada.Text_IO.Put_Line  -- line 27
        ("No_Exception_Propagation: this cannot happen...");
end Test_EH;
--------------------------------------------------------------------







  reply	other threads:[~2013-05-05 12:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-30 20:01 Extended Exceptions and other tweaks Diogenes
2013-03-30 22:10 ` Brian Drummond
2013-03-31  1:18   ` Diogenes
2013-04-01 20:36     ` Brian Drummond
2013-04-06 15:49       ` Lucretia
2013-04-07 20:20         ` rrr.eee.27
2013-04-08 10:21           ` Brian Drummond
2013-05-01 23:37             ` Brian Drummond
2013-05-02  1:06               ` Randy Brukardt
2013-05-05 12:41                 ` Brian Drummond [this message]
2013-05-07  0:39                   ` Randy Brukardt
2013-05-04  7:52     ` Yannick Duchêne (Hibou57)
2013-03-31 13:55   ` Luke A. Guest
2013-03-30 22:38 ` Shark8
2013-03-31 11:41 ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox