From: prichtmyer@yahoo.com (Peter Richtmyer)
Subject: Re: In case statment? (was Re: is exception when others => null; smart?)
Date: 30 Oct 2002 11:57:08 -0800
Date: 2002-10-30T19:57:08+00:00 [thread overview]
Message-ID: <1b585154.0210301157.5358caa1@posting.google.com> (raw)
In-Reply-To: CaNv9.103$eX2.5358@read2.inet.fi
"Anders Wirzenius" <anders.wirzenius@pp.qnet.fi> wrote in message news:<CaNv9.103$eX2.5358@read2.inet.fi>...
> "Peter Richtmyer" <prichtmyer@yahoo.com> 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
next prev parent reply other threads:[~2002-10-30 19:57 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-24 14:03 is exception when others => null; smart? Preben Randhol
2002-10-24 14:25 ` David C. Hoos, Sr.
2002-10-24 14:28 ` Preben Randhol
2002-10-24 14:38 ` Per Sandbergs
2002-10-25 15:04 ` Robert A Duff
2002-10-25 20:41 ` Dale Stanbrough
2002-10-26 23:04 ` Robert A Duff
2002-10-26 7:47 ` tmoran
2002-10-24 16:39 ` Mark Biggar
2002-10-24 20:06 ` Robert A Duff
2002-10-24 20:23 ` Wes Groleau
2002-10-25 1:16 ` Jeffrey Carter
2002-10-25 10:10 ` In case statment? (was Re: is exception when others => null; smart?) Preben Randhol
2002-10-25 14:59 ` Robert A Duff
2002-10-25 15:06 ` Preben Randhol
2002-10-29 18:23 ` Peter Richtmyer
2002-10-30 2:52 ` Steven Deller
2002-10-30 8:58 ` Anders Wirzenius
2002-10-30 19:57 ` Peter Richtmyer [this message]
2002-10-31 7:02 ` Anders Wirzenius
2002-10-30 9:36 ` Lutz Donnerhacke
2002-10-30 19:44 ` Peter Richtmyer
2002-10-30 13:28 ` Marin David Condic
2002-10-30 20:34 ` Robert Spooner
2002-10-31 12:40 ` In case statment? (was Re: is exception when others => null;smart?) Marin David Condic
2002-10-25 17:13 ` In case statment? <...> when others John Woodruff
2002-10-27 21:03 ` In case statment? (was Re: is exception when others => null; smart?) Ze Administrator
2002-10-28 10:04 ` Preben Randhol
2002-10-28 20:05 ` Wes Groleau
2002-10-30 11:31 ` Preben Randhol
2002-10-28 12:32 ` In case statment? (was Re: is exception when others => null;smart?) Adrian Hoe
2002-10-24 20:11 ` is exception when others => null; smart? Simon Wright
2002-10-24 21:22 ` Larry Kilgallen
2002-10-24 20:03 ` Robert A Duff
2002-10-25 1:49 ` SteveD
2002-10-25 3:48 ` Dennis Lee Bieber
2002-10-26 11:34 ` Preben Randhol
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox