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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC 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: George Haddad Subject: Re: Valid Attribute and Unchecked Conversion Date: 1996/10/02 Message-ID: <3252ED6B.1B74@lmco.com>#1/1 X-Deja-AN: 186789832 references: <1996Sep26.191257.1@eisner> content-type: text/plain; charset=us-ascii organization: Lockheed Martin M & S, Sunnyvale, CA mime-version: 1.0 reply-to: george.haddad@lmco.com newsgroups: comp.lang.ada x-mailer: Mozilla 2.02 (Macintosh; I; PPC) Date: 1996-10-02T00:00:00+00:00 List-Id: Robert I. Eachus wrote: > Change to: > > declare > type T is range 1 .. 10; > for T'SIZE use Integer'SIZE; > function To_T is new Unchecked_Conversion (Integer, T'Base); > O : T; > begin > begin > O := To_T (0); > exception when others => null; > end; > > if O'Valid then > ... > end; > > ...and you still don't get what you want. In this case the > O'Valid check may or may not succeed, depending on the initial junk in > that stack location. So, what about: declare type T is range 1 .. 10; function To_T is new Unchecked_Conversion (Integer, T); X : T; begin if To_T(0)'Valid then X := To_T(0); ... end; I realize that this involves calling the same function twice (which is probably not a problem given that the function is an instance of Unchecked_Conversion), but is the fragment above erroneous? -- I found these opinions on my doorstep, would you please give them a good home?