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=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 24 Sep 91 15:08:38 GMT From: jbg@sei.cmu.edu (John Goodenough) Subject: Re: Untyped "constant"? Message-ID: <32090@as0c.sei.cmu.edu> List-Id: In article Untyped "constant"? of 23 Sep 91 16:44:46 GMT gralia@ddsdx2.jhuapl.edu (Mars J. Gralia) writes: >a) Suppose I have a compiler/RTE in which integer'last is 32_767. >b) And suppose the system has a long_integer type in which > long_integer'last = 2_147_483_647. >c) And suppose I have the program: > procedure Named1 is > X : constant := integer'last+5; > begin > for j in 1..X loop > null; > end loop; > end Named1; >Then: is this a legal program or not? The named number declaration is illegal, because INTEGER'LAST is of type INTEGER (see 3.5(9)) and the initialization expression for a named number must have a universal type (see 3.2.2(1)). So suppose you fix this problem by writing: X : constant := INTEGER'POS(INTEGER'LAST) + 5; Note that INTEGER'POS returns a value of type universal integer (see 3.5.5(6)), INTEGER'LAST is a static expression (4.9(8)), and INTEGER'POS(INTEGER'LAST) is static (4.9(8)). But this doesn't solve the problem, since for J in 1..X loop is now equivalent to for J in 1..32_767+5 loop The upper and lower bounds of this range will be converted to the predefined INTEGER type (3.6.1(2)), and this conversion will raise CONSTRAINT_ERROR. John B. Goodenough Goodenough@sei.cmu.edu Software Engineering Institute 412-268-6391