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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news3.google.com!news.glorb.com!cycny01.gnilink.net!cyclone1.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny03.POSTED!0f19ed38!not-for-mail From: "Frank J. Lhota" Reply-To: NOSPAM.lhota@adarose.com User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada exception block does NOT work? References: <4301ab29$0$6989$9b4e6d93@newsread2.arcor-online.net> <1124185355.610972.22710@f14g2000cwb.googlegroups.com> In-Reply-To: <1124185355.610972.22710@f14g2000cwb.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <9AnMe.418$zb.194@trndny03> Date: Tue, 16 Aug 2005 15:25:57 GMT NNTP-Posting-Host: 141.154.216.240 X-Complaints-To: abuse@verizon.net X-Trace: trndny03 1124205957 141.154.216.240 (Tue, 16 Aug 2005 11:25:57 EDT) NNTP-Posting-Date: Tue, 16 Aug 2005 11:25:57 EDT Xref: g2news1.google.com comp.lang.ada:4136 Date: 2005-08-16T15:25:57+00:00 List-Id: I tried this program with ObjectAda, and found that ObjectAda did not have this problem. I also tried the following variant of this program, where I replaced all of the fixed decimal arithmetic with integer arithmetic. This version does compile and execute properly, so it appears that the problem is related to how GNAT handles fixed point arithmetic errors. --the test code is with Ada.Text_Io; procedure Trading is type Price is range -16#8000_0000# .. 16#7FFF_FFFF#; type Pricearray is array (Positive range <>) of Price; procedure Avg (Data : in Pricearray) is Avg, Sum : Price'Base := 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); begin Avg (Mydata); end; end loop; end loop; end Trading; ----end the test code -- "All things extant in this world, Gods of Heaven, gods of Earth, Let everything be as it should be; Thus shall it be!" - Magical chant from "Magical Shopping Arcade Abenobashi" "Drizzle, Drazzle, Drozzle, Drome, Time for the this one to come home!" - Mr. Lizard from "Tutor Turtle"