From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=BAYES_00,FROM_ADDR_WS autolearn=no autolearn_force=no version=3.4.5-pre1 Date: 22 Sep 93 13:36:56 GMT From: cis.ohio-state.edu!news.sei.cmu.edu!firth@ucbvax.Berkeley.EDU (Robert Fi rth) Subject: Re: Bug in AdaEd??? Message-ID: <1993Sep22.093656.20606@sei.cmu.edu> List-Id: In article eachus@spectre.mitre.org (R obert I. Eachus) writes: > But there are nasty examples where you need to rely on >CONSTRAINT_ERROR being raised. The worst example we came up with was: > > declare > subtype My_Int is Integer range 1..10_000; > X,Y: My_Int; > Junk: My_Int; > begin > Read(X); > Read(Y); > Junk := X*Y; > if Junk > 10_000 then Do_Something; end if; > exception > when others => Do_Something; > end; Indeed a nasty example! However, isn't the solution fairly simple: eliminate the variable Junk and rewrite the test as if X*Y > 10_000 then ... As far as I can see, that has to work regardless of whether X*Y overflows. Moreover, isn't it the obvious way to write the code?