From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_05 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 22 Sep 93 14:10:13 GMT From: cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland. reston.ans.net!usc!cs.utexas.edu!not-for-mail@ucbvax.Berkeley.EDU (Franco Mazz anti) Subject: Re: Bug in AdaEd??? Message-ID: <9309221412.AA02787@ieipisa.iei.pi.cnr.it> List-Id: >From: eachus@spectre.mitre.org (Robert I. Eachus) >Subject: Re: Bug in AdaEd??? > >Let me drag the logic out into plain (ugly) sight. > ... > 2) Therefore an optimizing compiler can eliminate any assignments > to A. > > 3) If the compiler eliminates the assignment, it can also (see > 11.6) eliminate the check. > I do not see anything in the Ada83 Reference Manual or ARG resolutions allowing this. > When Ada 83 was being defined, the principle reason for the >constraint checks on assignments was to prevent objects from having >invalid values. In the tradeoffs between speed and correctness, the >compromise was that initial values need not be checked (the raw bits >in memory allocated to the object, not the initial value expression) >for objects other than access types, but all subsequent assignments >would be. The case of assignments which were eliminated by >optimization was discussed, and 11.6(7) was the result. If you don't >do the assignment, you don't need to do the check. Paragraph 11.6(7) deals with predefined operators, but the assignment, or the check to be performed before an assignment are not predefined operators but "basic" operations (see Ref. Man 3.3.1). I am not surprised if some compilers, at some optimization levels do something illegal. Again, I cannot see in the Reference Manual anything allowing this interpretation. A confirmation of this also comes from the discussion of AI-00535/03 where it is clearly explained that: " No problem arises when operating on scalar values: declare type NB is new BOOLEAN range TRUE .. TRUE; A, B : NB := TRUE; begin if (not A) or (A xor B) then -- no exception is raised A := not A; -- CONSTRAINT_ERROR end if; end; No exception is raised for NOT A or A XOR B since the NOT and XOR operators for type NB are the predefined operators, which return values of the base type. " By the way, for a more precise picture it is possible to retrieve AI-00535/03 from host ajpo.sei.cmu.edu, directory public/ada-comment, file ai-00535-bi.wa. - - - - - - - - - - - - - - - - - - - - - - - - - - Dr. Franco Mazzanti Istituto di Elaborazione della Informazione Via S.Maria 46, 56126 Pisa, ITALY Tel: 050-593447/593400, Fax: 050-554342 e-mail: mazzanti@iei.pi.cnr.it - - - - - - - - - - - - - - - - - - - - - - - - - -