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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ee1a8b8db84c88f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!f14g2000cwb.googlegroups.com!not-for-mail From: gautier_niouzes@hotmail.com Newsgroups: comp.lang.ada Subject: Re: Ada exception block does NOT work? Date: 16 Aug 2005 02:42:35 -0700 Organization: http://groups.google.com Message-ID: <1124185355.610972.22710@f14g2000cwb.googlegroups.com> References: <4301ab29$0$6989$9b4e6d93@newsread2.arcor-online.net> NNTP-Posting-Host: 213.173.163.2 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1124185361 11746 127.0.0.1 (16 Aug 2005 09:42:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 16 Aug 2005 09:42:41 +0000 (UTC) User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: f14g2000cwb.googlegroups.com; posting-host=213.173.163.2; posting-account=CZAoAgwAAAD9ntJQ85OlWL0_Q5EFdzP_ Xref: g2news1.google.com comp.lang.ada:4131 Date: 2005-08-16T02:42:35-07:00 List-Id: It looks like a GNAT bug: 1st time with denominator 0 the division raises an exception, 2nd times it seems to enter an infinite loop. See the enhanced test. Did you try with ObjectAda (you can download it). Good (too) for cross-testing. HTH About stocks: here a series of Ada-generated Web pages :-) ---> http://homepage.sunrise.ch/mysunrise/gdm/ind1dlog.htm ______________________________________________________________ Gautier -- http://www.mysunrise.ch/users/gdm/index.htm Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site! --the test code is with Ada.Text_Io; procedure Trading is type Price is delta 0.01 digits 18; type Pricearray is array (Positive range <>) of Price; procedure Avg (Data : in Pricearray) is Avg, Sum : Price'Base := 0.0; begin Ada.Text_Io.Put ("average:" ); for Index in Data'Range loop Sum := Sum + Data (Index); end loop; Ada.Text_Io.Put("#a"); Avg := Sum / Data'Length; -- <- blocking there on the 2nd try with denominator 0 Ada.Text_Io.Put("#b"); Ada.Text_Io.Put (Price'Image (Avg)); Ada.Text_Io.New_Line; exception when others => Ada.Text_Io.Put_Line ("error here!"); end; begin for Index in reverse 0 .. 9 loop Ada.Text_Io.Put_Line ("Main index " & Natural'Image (Index)); for Step in 1 .. 3 loop Ada.Text_Io.Put_Line ("Step " & Natural'Image (Step)); declare Mydata : Pricearray (1 .. Index) := (others => 10.0); begin Avg (Mydata); end; end loop; end loop; end Trading; ----end the test code