From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,468faeb0abcd305e X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.224.10.6 with SMTP id n6mr29070059qan.4.1367757911831; Sun, 05 May 2013 05:45:11 -0700 (PDT) Path: y6ni11038qax.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.bbs-scene.org!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Extended Exceptions and other tweaks. Date: Sun, 5 May 2013 12:41:41 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <39102c40-a4e3-4991-a94a-d7d51856c83d@googlegroups.com> <3c252206-989c-40c6-838f-6a37eeac9349@googlegroups.com> Mime-Version: 1.0 Injection-Date: Sun, 5 May 2013 12:41:41 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="da745e888d4a5182b5fda6212bbb0a63"; logging-data="4073"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+W6ldi/ytQrH+WLrA4IOgFcvVAtpfEyoY=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:1A3FX7oTOm0c/NdAC1z+XX3EEvY= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2013-05-05T12:41:41+00:00 List-Id: On Wed, 01 May 2013 20:06:20 -0500, Randy Brukardt wrote: > "Brian Drummond" 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; --------------------------------------------------------------------