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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,139d9b90ab37c0e5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-26 16:44:33 PST Path: archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3BD9F556.CE3E522D@acm.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: When to do a constraint check and not ?? References: <3BD91EF8.EEB7EDBA@systems.saab.se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 26 Oct 2001 23:44:29 GMT NNTP-Posting-Host: 63.180.2.44 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1004139869 63.180.2.44 (Fri, 26 Oct 2001 16:44:29 PDT) NNTP-Posting-Date: Fri, 26 Oct 2001 16:44:29 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Fri, 26 Oct 2001 16:40:38 PDT (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:15288 Date: 2001-10-26T23:44:29+00:00 List-Id: Per Sandberg wrote: > > Assume the folowing code: > > procedue bla is > b : boolean; --< B may contain any bit pattern at this point. > > procedure test( p : in out boolean ) is > begin > b := false; > end test; > > begin > test(b); --<< Is the compiler allowed to insert a constraint check on b > here ?? > end; > > Is the answer that it is up to the wendor. > I did not get any clues from the LRM. The answer is that you have incorrectly specified the parameter mode of P in Test. Since you do not reference the in value of P, the mode should be out. The compiler is required to insert a constraint check on B if it has a subtype different from P, see 6.4.1(11). The subtype conversion and assignment mentioned require a range check, just as if you did them manually. In this case B and P have the same subtype, so the compiler may assume the value of B is valid for the subtype and eliminate the range check. However, it is not required to eliminate the check, so the above appears to be a bounded error. -- Jeff Carter "I wave my private parts at your aunties." Monty Python & the Holy Grail