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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.41.74 with SMTP id p71mr14930365itp.11.1511779632735; Mon, 27 Nov 2017 02:47:12 -0800 (PST) X-Received: by 10.157.33.82 with SMTP id l18mr1657346otd.6.1511779632664; Mon, 27 Nov 2017 02:47:12 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!peer01.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!i6no7313655itb.0!news-out.google.com!x87ni5218ita.0!nntp.google.com!193no903476itr.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 27 Nov 2017 02:47:12 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=85.167.214.186; posting-account=bPTmZAoAAAC_6HP9XLKB9aAAxBa6BuOR NNTP-Posting-Host: 85.167.214.186 References: <7c246c12-77f6-45c9-a05a-9afe934df332@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <19ca49f7-fa8c-49d9-a4b8-8a77546ef3b5@googlegroups.com> Subject: Re: Strange warning message From: reinert Injection-Date: Mon, 27 Nov 2017 10:47:12 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Body-CRC: 4095882181 X-Received-Bytes: 2717 Xref: reader02.eternal-september.org comp.lang.ada:49184 Date: 2017-11-27T02:47:12-08:00 List-Id: On Monday, November 27, 2017 at 11:42:11 AM UTC+1, Jeffrey R. Carter wrote: > On 11/27/2017 09:40 AM, reinert wrote: > > > > when I compile the enclosed program with option "-gnatwa" (i.e. "gnatmake -gnatwa test1k.adb", I get the following annoying warning: > > > > "warning: useless assignment to "test1", value never referenced" > > In order to produce warnings like this, the compiler has to do some data-flow > analysis. The amount of data-flow analysis required by the ARM is zero. So GNAT > is making an extra effort to be helpful. That the warning is annoying in this > case is the price you pay for it being correct in most others. > > Clearly GNAT's data-flow analysis is incomplete, or it would also flag the > assignment in the loop. Complete data-flow analysis is possible (SPARK does it). > but apparently it's hard, and possibly not really compatible with a compiler's > main purpose, but even if GNAT did have complete data-flow analysis, you'd still > get the warning. > > I found that even if I change the loop to > > for I in Test1'range loop > Test1 (I) := new Test1_T; > end loop; > > GNAT (7.2) still doesn't flag the assignment in the loop, so it's not just that > GNAT's analysis hasn't caught up with the new "for E of" construct. > > -- > Jeff Carter > "We burst our pimples at you." > Monty Python & the Holy Grail > 16 This clarifies, reinert