From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Strange warning message
Date: Mon, 27 Nov 2017 11:42:09 +0100
Date: 2017-11-27T11:42:09+01:00 [thread overview]
Message-ID: <ovgq61$cu4$1@dont-email.me> (raw)
In-Reply-To: <7c246c12-77f6-45c9-a05a-9afe934df332@googlegroups.com>
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
next prev parent reply other threads:[~2017-11-27 10:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-27 8:40 Strange warning message reinert
2017-11-27 9:00 ` Jacob Sparre Andersen
2017-11-27 9:13 ` reinert
2017-11-27 9:45 ` Jacob Sparre Andersen
2017-11-27 10:43 ` reinert
2017-11-27 9:01 ` gautier_niouzes
2017-11-27 9:09 ` gautier_niouzes
2017-11-27 9:27 ` reinert
2017-11-27 10:42 ` Jeffrey R. Carter [this message]
2017-11-27 10:47 ` reinert
2017-11-27 11:52 ` reinert
2017-11-29 0:43 ` Robert Eachus
2017-11-29 10:39 ` reinert
2017-11-29 20:47 ` Randy Brukardt
2017-11-30 14:11 ` reinert
2017-12-01 22:53 ` Robert Eachus
2017-12-02 8:47 ` Simon Wright
2017-12-02 9:47 ` Niklas Holsti
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox