comp.lang.ada
 help / color / mirror / Atom feed
From: Phil Thornley <phil.jpthornley@gmail.com>
Subject: Re: Question about SPARK flow error.
Date: Sat, 19 Jun 2010 16:28:08 -0700 (PDT)
Date: 2010-06-19T16:28:08-07:00	[thread overview]
Message-ID: <78a3a0d8-9216-4c55-a586-162995f41046@q12g2000yqj.googlegroups.com> (raw)
In-Reply-To: 4c1cf6a3$0$30803$4d3efbfe@news.sover.net

On 19 June, 17:58, "Peter C. Chapin" <pcc482...@gmail.com> wrote:
[...]
Well, I was also wrong about using the non-existence of an unprovable
VC as evidence to support an accept annotation!

Using your code, the Simplifier proves all the VCs - and it still does
even if I remove either of the assignments to Index (and so create a
genuine data flow error).

The 'exit' VCs for a procedure are "trivially true" unless there is a
post-condition.  All exported values are assumed to be valid at this
point because the RTC analysis ***assumes that there are no data-flow
errors*** - i.e.:
1. all exports must have been assigned a value (otherwise there will
be a data-flow error), and
2. all values assigned must be valid otherwise there will be an
unprovable VC.

So it seems to me that:
The best way to deal with the error is an accept annotation.
Such an annotation is a potential risk as it may hide a genuine data
flow error (if not now then maybe when the code is changed at some
point in the future).

Consequently it makes sense to force a check on the relevant value by
adding a check annotation.

So, how about adding the following at the end of your procedure:
   --# accept F, 602, Index, Index,
   --#        "The following check ensures that there is no actual
error.";
   --# check Index in Index_Type;
end Add_Item;

This eliminates the reported flow error, and creates an unprovable VC
if there is any genuine data flow error for Index.
(It also needs a assertion in the loop: --# assert not Found;)

HTH

Phil



  parent reply	other threads:[~2010-06-19 23:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-19 16:58 Question about SPARK flow error Peter C. Chapin
2010-06-19 18:03 ` Phil Thornley
2010-06-19 18:23   ` Gavino
2010-06-19 19:24     ` Phil Thornley
2010-06-19 18:14 ` Gavino
2010-06-19 19:29   ` Phil Thornley
2010-06-19 23:28 ` Phil Thornley [this message]
2010-06-20  0:37   ` Peter C. Chapin
2010-06-20  8:42     ` Phil Thornley
replies disabled

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