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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,45a9122ddf5fcf5 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Valid Attribute and Unchecked Conversion Date: 1996/10/02 Message-ID: #1/1 X-Deja-AN: 186736896 references: <1996Oct1.100608.1@eisner> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-10-02T00:00:00+00:00 List-Id: In article , Matthew Heaney wrote: >So it's legal to check (using the valid attribute) the value of a (scalar) ^^^^^ you me "not erroneous". >object with an invalid representation, right? Right. >Given the following program: > > declare > type T is range 1 .. 10; > function To_T is new Unchecked_Conversion (Integer, T); > O : constant T := To_T (0); I can't read that clearly on my screen, but I assume the variable name is the letter oh, and the expression is the number zero. ;-) > begin > if O'Valid then > ... > end; > >I want to know if the program is correct. Is it erroneous, yes or no? This is essentially the same as the example in 13.9.1(12.d), which I posted a couple of days ago. It is erroneous, by 13.9.1(12). This has nothing to do with the 'Valid attribute -- the above program becomes erroneous before it gets to the 'Valid. What I mean is, it's not that 'Valid doesn't work. It's that Unchecked_Conversion is explicitly defined to be erroneous in the above case. Note that the rules for I/O are somewhat different than for unchecked_conversion, primarily because function results are different from 'out' parameters. - Bob