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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,3737542e2ed2b8e1 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!d7g2000prl.googlegroups.com!not-for-mail From: johnscpg@googlemail.com Newsgroups: comp.lang.ada Subject: Re: Problem with optimizations Date: Wed, 29 Apr 2009 03:45:37 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1995d1f1-55c3-43f5-98db-ab6c5396b4bd@d7g2000prl.googlegroups.com> References: <49f73730$0$2850$ba620e4c@news.skynet.be> <49f755e0$0$2850$ba620e4c@news.skynet.be> NNTP-Posting-Host: 143.117.23.126 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1241045817 10239 127.0.0.1 (29 Apr 2009 22:56:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 29 Apr 2009 22:56:57 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d7g2000prl.googlegroups.com; posting-host=143.117.23.126; posting-account=Jzt5lQoAAAB4PhTgRLOPGuTLd_K1LY-C User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.0.7) Gecko/2009032813 Iceweasel/3.0.6 (Debian-3.0.6-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5612 Date: 2009-04-29T03:45:37-07:00 List-Id: On Apr 28, 8:15=A0pm, Olivier Scalbert wrote: > Albrecht K=E4fer wrote: > > (see below) schrieb:: > >> There is no else part for the following if: > > >> =A0 =A0 =A0 =A0 =A0 =A0 if Is_Solved(Cube) then > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 New_Line; > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Put("Solved !"); New_Line; > > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for i in 1..depth-1 loop > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Ada.Integer_Text_IO.Put(Intege= r(Moves(i))); > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 end loop; > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Result :=3D True; > >> =A0 =A0 =A0 =A0 =A0 =A0 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 expe= ct. > > > 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 have to have -O to get the -W to work when you are looking for uninitialized variables. Exactly as you've shown, it flags variables that may or may not be initialized in for loops, or if then else blocks. Its usually wrong, (it speculates) but I like it. In gfortan you can write -O - Wuninitialized; probably same with gnatmake (it accepts it anyway). cheers, jonathan