comp.lang.ada
 help / color / mirror / Atom feed
From: johnscpg@googlemail.com
Subject: Re: Problem with optimizations
Date: Wed, 29 Apr 2009 06:51:25 -0700 (PDT)
Date: 2009-04-29T06:51:25-07:00	[thread overview]
Message-ID: <851c05e8-8471-445a-a1a3-23e454205b32@u39g2000pru.googlegroups.com> (raw)
In-Reply-To: 49f755e0$0$2850$ba620e4c@news.skynet.be

On Apr 28, 8:15 pm, Olivier Scalbert <olivier.scalb...@algosyn.com>
wrote:
> Albrecht Käfer wrote:
> > (see below) schrieb::
> >> There is no else part for the following if:
>
> >>             if Is_Solved(Cube) then
> >>                 New_Line;
> >>                 Put("Solved !"); New_Line;
>
> >>                 for i in 1..depth-1 loop
> >>                     Ada.Integer_Text_IO.Put(Integer(Moves(i)));
> >>                 end loop;
> >>                 Result := True;
> >>             end if;
>
> >> So the procedure can exit with Result undefined. Since the program is
> >> incorrect, varying optimisation, or implementation details, is likely to
> >> give varying results. Some may co-incidentally be the results you expect.
>
> > Shouldn't that, you know, create a warning or something?
>
> > Albrecht
>
> That is what I was thinking, but with:
>
> gnatmake -f -O3 -W -gnatp rubikmain
>
> it detects the bug (and also an other one in the same function)
>
> Shame on me !

I also learned this recently using gfortran.
You need the -O flag along with the -W to
get the gcc compiler to report uninitialized
variables.  As you've shown, it spots possible
uninitialized variables in  if-then-else
blocks or for-loops.  It mostly speculates - its
usually wrong, but I like it. In gfortran
you can limit the -W with: -O -Wuninitialized.
Don't know about gnatmake, but
gnatmake  accepts it.

cheers
jonathan

(This will be my 3rd and final attempt to post this -
hope 3 of these posts don't eventually appear,
but I can't seem to get gmail to let me through.
It sure likes spam tho' ;)



  parent reply	other threads:[~2009-04-29 13:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28 17:04 Problem with optimizations Olivier Scalbert
2009-04-28 17:34 ` Albrecht Käfer
2009-04-28 17:54   ` Olivier Scalbert
2009-04-28 18:32     ` Albrecht Käfer
2009-04-28 19:15     ` John B. Matthews
2009-04-28 18:40 ` (see below)
2009-04-28 19:05   ` Albrecht Käfer
2009-04-28 19:15     ` Olivier Scalbert
2009-04-28 19:17       ` Olivier Scalbert
2009-04-28 19:26         ` Gautier
2009-04-28 21:33       ` sjw
2009-04-29 10:36       ` johnscpg
2009-04-29 10:45       ` johnscpg
2009-04-29 13:51       ` johnscpg [this message]
2009-04-28 19:06   ` Olivier Scalbert
2009-04-28 19:12     ` (see below)
2009-04-29  2:35       ` Gene
2009-04-29  3:28         ` (see below)
2009-04-29  7:05           ` Georg Bauhaus
2009-04-28 19:46 ` Gautier
2009-04-28 20:05   ` Olivier Scalbert
2009-04-28 20:21   ` Olivier Scalbert
replies disabled

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