comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!news.sei.cmu.edu!firth@ucbvax.Berkeley.EDU  (Robert Fi
Subject: Re: Bug in AdaEd???
Date: 22 Sep 93 13:36:56 GMT	[thread overview]
Message-ID: <1993Sep22.093656.20606@sei.cmu.edu> (raw)

In article <EACHUS.93Sep21192111@spectre.mitre.org> 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?

             reply	other threads:[~1993-09-22 13:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-09-22 13:36 cis.ohio-state.edu!news.sei.cmu.edu!firth [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-09-23 20:55 Bug in AdaEd??? Tucker Taft
1993-09-23 18:46 Tucker Taft
1993-09-22 22:28 Robert I. Eachus
1993-09-22 21:07 Robert I. Eachus
1993-09-22 14:22 Norm an H. Cohen
1993-09-22 14:10 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland.reston.ans.net!usc!cs.utexas.edu!not-for-mail
1993-09-22 11:45 Wes Groleau x1240 C73-8
1993-09-22  0:21 Robert I. Eachus
1993-09-21  4:19 Gene Ouye
1993-09-07  3:20 Robert Dewar
1993-09-06 14:06 Gene Ouye
replies disabled

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