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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9ae5f4553aae9277 X-Google-Attributes: gid103376,public From: rgilbert@polaris.orl.mmc.com (Bob Gilbert) Subject: Re: What's wrong with this syntax? Date: 1996/12/05 Message-ID: <587aul$hrd@zeus.orl.mmc.com>#1/1 X-Deja-AN: 203312244 references: <32A6FE0F.7902@lmtas.lmco.com> organization: Lockheed Martin Electronics and Missiles reply-to: rgilbert@polaris.orl.mmc.com newsgroups: comp.lang.ada Date: 1996-12-05T00:00:00+00:00 List-Id: John Gluth wrote: > > Howdy, > > Someone on my team asked me if I knew why Rational's Apex doesn't > seem to like the following excerpts. I don't see what's wrong with it > either. > > Some_Limit : Constant := 1024; > > for i in 1..(Some_Limit - 2) loop > > It doesn't seem to want to evaluate the (Some_Limit - 2) expression. > It seems to me that Some_Limit, a named number is of type Universal > Integer. > The literal, 2, should also be of type Universal Integer. > > What are we missing? > Then Ken Garlington replied: > Here's what DEC Ada V3.2-12 says about your loop: > > "Type {universal_integer} is not allowed for the discrete range of a constrained > array definition, an iteration rule, or an index of an entry family [LRM 3.6.1(2)]. > Default resolution to the type INTEGER does not apply because one or both expressions > is not a literal, named number, or attribute; however, the type INTEGER is assumed > [LRM 3.6.1(2)]." > > Note that both references are to the Ada 83 LRM. > > There are several approaches to fixing the problem; one is > > "for I in Integer'(1) .. (Some_Limit - 2) loop" > > Your code does compile correctly on an Ada 95 compiler (GNAT). The code compiled without errors using a Tartan C40 compiler (Ver 5.1). This was true for whether the 9x options switch was off (Ada 83) or on (some Ada 95 features available). Curious. -Bob