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,64afbf156d06bbe7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-26 11:18:18 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread4.news.pas.earthlink.net.POSTED!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: 'Valid, subtypes and constraint checking References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 26 Sep 2003 18:18:17 GMT NNTP-Posting-Host: 63.184.105.179 X-Complaints-To: abuse@earthlink.net X-Trace: newsread4.news.pas.earthlink.net 1064600297 63.184.105.179 (Fri, 26 Sep 2003 11:18:17 PDT) NNTP-Posting-Date: Fri, 26 Sep 2003 11:18:17 PDT Xref: archiver1.google.com comp.lang.ada:43011 Date: 2003-09-26T18:18:17+00:00 List-Id: Peter Amey wrote: > ExternalPort : T; > Temp : T; -- note same SUBtype as the port > ... > Temp := ExternalPort; -- no checks generated because same subtype > if Temp'Valid then > -- we can use value safely > else > -- handle error safely > end if; If External_Port can take on values not in T, then it should not be considered of subtype T. For example subtype T is Unsigned_8 range 2#0000_0000# .. 2#0000_1111#; External_Port : Unsigned_8; for External_Port'Address use ...; pragma Volatile (External_Port); Temp_8 : Unsigned_8; Temp : T; ... Temp_8 := External_Port; if Temp_8 not in T then raise An_Appropriate_Exception; end i;f 'Valid is perhaps more appropriate for a value obtained from Unchecked_Conversion, or portions of the software where it has been necessary to turn of checking: External_Port : T; -- clauses ... declare pragma Suppress ...; begin Temp := External_Port; end; if not Temp'Valid then raise ...; end if; -- process Temp -- Jeff Carter "Death awaits you all, with nasty, big, pointy teeth!" Monty Python & the Holy Grail 20