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.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ihnp4!homxb!houxm!hjuxa!petsd!cjh From: cjh@petsd.UUCP Newsgroups: comp.lang.ada Subject: Re: language problem Message-ID: <998@petsd.UUCP> Date: Wed, 1-Apr-87 15:12:44 EST Article-I.D.: petsd.998 Posted: Wed Apr 1 15:12:44 1987 Date-Received: Sat, 4-Apr-87 07:22:57 EST References: <8703261730.AA28726@taurus> <997@petsd.UUCP> Reply-To: cjh@petsd.UUCP (C. J. Henrich) Distribution: world Organization: Perkin-Elmer DSG, Tinton Falls, N.J. List-Id: [] In article <997@petsd.UUCP> joe@petsd.UUCP (Joseph M. Orost) writes: >In article <8703261730.AA28726@taurus> amiram@TAURUS.BITNET.UUCP writes: >>A colleague of mine, Yossi Veler of AITECH has come up with the following >>program in Ada, which seems to create a serious problem. >> >>procedure boolsub is >> subtype bool is boolean range true..true; >> type arr is array(1..10) of bool; >> a : arr := (1..10 => true); -- this seems like the only legal value >>begin >> a := not a; >>-- Here a(1)=a(2)=...=a(10)= FALSE !!!! No exception occurs etc. >> a := (1..10 => false); >>-- This does cause an exception >>end boolsub; >> >>The program seems legal : we inspected the LRM and also the implementers >>guide, and we ran it on both the DDC and VERDIX compilers. It seems that >>a combination of innocent features in Ada produces a result that seems to >>contradict with the basic philosophy of the language, that is an object >>posseses a value which is not in the appropriate type. > >Our compiler (C3Ada R00-01.02/Beta) correctly raises CONSTRAINT_ERROR on the >statement "a := not a;". > Why is this statement illegal? Well... what is the type of the expression "not a" ? It can't be "arr" because its components do not satisfy the subrange constraint. And there isn't any available type with boolean components. The type "arr" may look like a subtype of "ARRAY(1..10) of boolean", but it isn't. On arrays, subtype constraints affect the bounds of indexes, not the values of components. Regards, Chris -- Full-Name: Christopher J. Henrich UUCP: ...!hjuxa!petsd!cjh US Mail: MS 313; Concurrent Computer Corporation; 106 Apple St; Tinton Falls, NJ 07724 Phone: (201) 758-7288 Concurrent Computer Corporation is a Perkin-Elmer company.