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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1e4bb63e08046e1a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-30 11:57:08 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: prichtmyer@yahoo.com (Peter Richtmyer) Newsgroups: comp.lang.ada Subject: Re: In case statment? (was Re: is exception when others => null; smart?) Date: 30 Oct 2002 11:57:08 -0800 Organization: http://groups.google.com/ Message-ID: <1b585154.0210301157.5358caa1@posting.google.com> References: <3DB8204B.2080804@attbi.com> <3DB89B83.2060609@acm.org> <1b585154.0210291023.70af4929@posting.google.com> NNTP-Posting-Host: 164.223.72.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1036007828 18171 127.0.0.1 (30 Oct 2002 19:57:08 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 30 Oct 2002 19:57:08 GMT Xref: archiver1.google.com comp.lang.ada:30239 Date: 2002-10-30T19:57:08+00:00 List-Id: "Anders Wirzenius" wrote in message news:... > "Peter Richtmyer" wrote in message > news:1b585154.0210291023.70af4929@posting.google.com... > > > As the following example illustrates, it really depends upon > > the compiler too. A "bad" value is handled differently as > > shown: > > ----------------------------------------------------------- > > with system; > > with text_io; > > procedure test is > > > > a : character := character'val(2#11111111#); > > for a'size use 8; > > b : boolean; > > for b'address use a'address; > > for b'size use 8; > > > > begin > > > > case b is > > when true => > > text_io.put_line ("b is true"); > > when false => > > text_io.put_line ("b is false"); > > when others => > > text_io.put_line ("ObjectAda for Windows V7.1.105 " & > > "professional " edition gets here, " & > > "and so does Rational Apex Ada 95 v. 4.0.0b"); > > end case; > > > > exception > > when others => > > text_io.put_line ("Gnat 3.14P gets here "); > > end test; > > --------------------------------------------------------------- > > But if you move the assignment to after begin, the Gnat behaviour changes: > ... > a : character; > for a'size use 8; > b : boolean := false; > for b'address use a'address; > for b'size use 8; > > begin > a := character'val(2#11111111#); > ... > and the program execution ends up under when others => > > Anders Were you using Gnat ? I tried it your way and still got the exception (which is the behavior I like). I also tried it your way, but with the 'a' data definition of null char: a : character := character'val(0); for a'size use 8; b : boolean; for b'address use a'address; for b'size use 8; begin a := character'val(2#11111111#); and still got the exception on Gnat. Which is what I would expect (on Gnat). Peter