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: 103376,d679dd7e9c16805a X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news.in2p3.fr!in2p3.fr!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: Selective suppression of warnings --- gnat on GNU/Linux Date: Wed, 31 Dec 2008 10:46:34 +0100 Organization: Adalog Message-ID: <42ffjg.s9b.ln@hunter.axlog.fr> References: <7a6baa71-80e8-4f3a-80b6-34935bda2fc0@r10g2000prf.googlegroups.com> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1230710695 11580 195.25.228.57 (31 Dec 2008 08:04:55 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Wed, 31 Dec 2008 08:04:55 +0000 (UTC) User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:4121 Date: 2008-12-31T10:46:34+01:00 List-Id: Robert A Duff a �crit : > 1. subtype T is Integer range A..B; > 2. type T is new Integer range A..B; > 3. type T is range A..B; > [...] > Option 3 is questionable, because of overflow semantics for intermediate > results in expressions. In Pascal, if you say (X+Y)/2, it won't > overflow if X+Y is in Integer, but not in A..B. Same is True in Ada for > option 2, but not necessarily for option 3. Oh no! Option 2 has exactly the same problem, you just hope that by forcing your type to have the same number of bits as Integer (a type you know nothing about), there will be enough room for your computations... If you are worried about overflows (and you use only additions), the proper declarations are: type Big_Enough is range A .. 2*B; subtype T is Big_Enough range A .. B; Of course, if you compute more than single additions, a real analysis has to be done to determine the bounds of Big_Enough. By all means, please, let's get rid of Integer! -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr