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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,453ed54f02292eea X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Simple Ada question Date: 2000/05/22 Message-ID: <8gbmnb$2b4$1@hobbes2.crc.com>#1/1 X-Deja-AN: 625910953 References: <8f8fm5$de5$1@news.uit.no> <3923B647.82A765D4@bton.ac.uk> <8g8q19$amd$1@nnrp1.deja.com> <392934E9.FA87156E@bton.ac.uk> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: abuse@crc.com X-Trace: hobbes2.crc.com 959012395 2404 198.175.145.56 (22 May 2000 16:19:55 GMT) Organization: CRC: A wholly owned subsidiary of Thermo Electron X-MSMail-Priority: Normal NNTP-Posting-Date: 22 May 2000 16:19:55 GMT Newsgroups: comp.lang.ada Date: 2000-05-22T16:19:55+00:00 List-Id: John English wrote in message news:392934E9.FA87156E@bton.ac.uk... > Ehud Lamm wrote: > > On Sun, 21 May 2000, Robert Dewar wrote: > > > > |In article <3923B647.82A765D4@bton.ac.uk>, > > |John English wrote: > > |> I've seen enough students fall over this one that I wonder if a > > |> compiler warning should be issued if the loop index has the same > > |> name as a variable in the enclosing scope... > > | > > |In practice, GNAT will almost always give a warning in this > > |case. If the outer variable is not referenced at all, then > > |that will certainly generate a warning. If the outer variable > > |is referenced after the loop, then a warning will be generated > > |about reference to an uninitialized variable. > > | > > |This will not catch 100% of cases, but it's very close > > > > Actually a student came to me saying "I found a compiler bug" it says that > > i is not referenced, where as I clearly use it in the for loop.... > > Which is why I think a more explicit warning might be a good thing: > "loop index uses the same name as an existing object" or something > like that (although I'm sure the wording could be improved...) since > this is nearly always an indication of an error where the writer > believes that the two names will refer to the same thing. > > Just a thought... > One Ada83 compiler issues a warning (IIRC) like "I' declared at line xxx hides declaration at line yyy.