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: mheaney@ni.net (Matthew Heaney) Subject: Re: Valid Attribute and Unchecked Conversion Date: 1996/10/02 Message-ID: #1/1 X-Deja-AN: 186870167 references: <1996Sep26.191257.1@eisner> <52hnvh$li0@wdl1.wdl.lmco.com> <1996Oct1.100608.1@eisner> content-type: text/plain; charset=ISO-8859-1 organization: Estormza Software mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-10-02T00:00:00+00:00 List-Id: In article , eachus@spectre.mitre.org (Robert I. Eachus) wrote: > declare > type T is range 1 .. 10; > for T'SIZE use Integer'SIZE; > function To_T is new Unchecked_Conversion (Integer, T'Base); > O : constant T := To_T (0); > begin > if O'Valid then > ... > end; > >Now To_T returns a bit pattern that is legal for the type (T'Base), >and the constraint check occurs on the assignment. You never get to >the call to O'Valid. Thank you! That clears it up. I didn't realize that a Constraint_Check ever could ever occur upon assignment of a value returned by an instantiation of Unchecked_Conversion. But your method forces a Constraint_Check to occur by making the type of object O a subtype of the type returned by the function. (Technically, makes the function return a supertype of O's type. Did I get that right?) Very nice! Matt -------------------------------------------------------------------- Matthew Heaney Software Development Consultant mheaney@ni.net (818) 985-1271