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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!lll-winken!ames!pasteur!ucbvax!skvax1.csc.ti.com!linnig From: linnig@skvax1.csc.ti.com Newsgroups: comp.lang.ada Subject: nasty language rules for fixed_type'last Message-ID: <8901271633.AA16167@ti.com> Date: 27 Jan 89 16:24:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: I was astonished to learn that it is possible to raise an exception by using 'FIRST or 'LAST on a fixed point type. Apparently, it is possible to specify a fixed point type that cannot represent 'FIRST or 'LAST. The following is an example: 1|PROCEDURE fixedtest IS 2|TYPE f IS DELTA 1.0 RANGE 0.0 .. 32767.9; 3| 4|x: f; 5|BEGIN 6| x:= f'last; ^1 *** 1 Warn 4005: This operation will raise numeric_error at runtime because *** of arithmetic overflow or because the result is not representable in *** the target type format 7|END; [TARTAN Ada VMS/1750A, Version V2.05] The following paragraphs from the Ada LRM (3.5.9 and Appendix A) seems to allow this behavior: "For a fixed point constraint that includes a range constraint, the model numbers comprise zero and all multiples of small whose mantissa can be expressed using exactly B binary digits, where the value of B is chosen as the smallest integer number for which each bound of the specified range is either a model number or lies at most small distant from a model number." "P'FIRST For a prefix P that denotes a scalar type, or a subtype of a scalar type: Yields the lower bound of P. The value of this attribute has the same type as P. (See 3.5.)" For the language to allow 'FIRST and 'LAST to raise exceptions seems very dangerous. At least (for this example) it can be caught at compile time. Mike Linnig, Texas Instruments