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: Rules for Representation of Subtypes Date: 1996/09/29 Message-ID: #1/1 X-Deja-AN: 186112098 references: <1996Sep26.191257.1@eisner> <1996Sep28.155354.1@eisner> <1996Sep29.082143.1@eisner> content-type: text/plain; charset=ISO-8859-1 organization: Estormza Software mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-09-29T00:00:00+00:00 List-Id: In article <1996Sep29.082143.1@eisner>, kilgallen@eisner.decus.org (Larry Kilgallen) wrote: >But my X'valid should still work. And compilers are not allowed to >change the flow of a program. > > X := my_unchecked_conversion(Y); > > if X'valid > then > Z(247) := X; > else > raise my_exception; > end if; > >No optimizer should stash my X into Z until it determines the >result of my conditional. Likewise for: > > X:= my_unchecked_conversion(Y); > > if not X'valid then raise my_exception; end if; > > Z(247) := X; > >no optimizer should stash my X into Z until it knows the result >of the possible flow control change represented by raise my_exception. You raise a good point: no optimizer "should" stash X into Z until the expression is evalutated. But what is the rule for optimization of expressions involving the Valid attribute? The AARM95, Section 13.9.2 discusses the use of that attribute, but doesn't have anything to say about whether it is allowed to be optimized away. My hunch is that a compiler will not optimize away the use of the Valid attribute to check the results of Unchecked_Conversion, because that is one the cases explicity called out in the RM95 for its use. >Larry Kilgallen Matt -------------------------------------------------------------------- Matthew Heaney Software Development Consultant mheaney@ni.net (818) 985-1271