comp.lang.ada
 help / color / mirror / Atom feed
From: "John B. Matthews" <nospam@nospam.invalid>
Subject: Re: X := X; Compiler Warning?
Date: Mon, 12 Apr 2010 12:27:33 -0400
Date: 2010-04-12T12:27:33-04:00	[thread overview]
Message-ID: <nospam-EBAEFB.12273312042010@news.aioe.org> (raw)
In-Reply-To: Xns9D586C840409EWarrensBlatherings@188.40.43.213

In article <Xns9D586C840409EWarrensBlatherings@188.40.43.213>,
 Warren <ve3wwg@gmail.com> wrote:

> This weekend, I discovered a problem after some
> effort in debugging. The culprit was something
> stupid like this:
> 
>   Position_X : Line_Index := ...
> begin
> 
>   loop
>     ..
>     Position_X := Position_X;  -- whoops
>     ..
>     exit when ...;
>   end loop;
> 
> Obviously, that should have been coded as:
> 
>     Position_X := Position_X + 1;
> 
> As outlined here, it is trivial to spot. 
> 
> But with the longer variable names (in the original
> code), I somehow missed it in amongst all of the
> other statements.
> 
> Now isn't this something that is normally reported
> as a warning?  I'm using gnat, so perhaps I need an
> additional compiler option.

Add "-gnatwXX" to your "-cargs" in gnatmake, where XX is among these

<http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gnat_ugn_unw/
Warning-Message-Control.html#Warning-Message-Control>

For example, -gnatwr yields

warning: useless assignment of "Position_X" to itself

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



  reply	other threads:[~2010-04-12 16:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-12 14:40 X := X; Compiler Warning? Warren
2010-04-12 16:27 ` John B. Matthews [this message]
2010-04-12 17:39   ` Warren
replies disabled

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