comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Simple Ada question
Date: 2000/05/22
Date: 2000-05-22T16:19:55+00:00	[thread overview]
Message-ID: <8gbmnb$2b4$1@hobbes2.crc.com> (raw)
In-Reply-To: 392934E9.FA87156E@bton.ac.uk


John English <je@bton.ac.uk> 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 <je@bton.ac.uk> 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.







  reply	other threads:[~2000-05-22  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <8f8fm5$de5$1@news.uit.no>
2000-05-16  0:00 ` Simple Ada question Robert A Duff
2000-05-18  0:00   ` John English
2000-05-21  0:00     ` Robert Dewar
     [not found]       ` <Pine.A41.3.96-heb-2.07.1000521193502.30412B-100000@pluto.mscc.huji.ac.il>
2000-05-22  0:00         ` John English
2000-05-22  0:00           ` David C. Hoos, Sr. [this message]
2000-05-22  0:00           ` Ehud Lamm
2000-05-16  0:00 ` Jeff Carter
2000-05-16  0:00 ` tmoran
2000-05-16  0:00 ` Gisle S�lensminde
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox