comp.lang.ada
 help / color / mirror / Atom feed
From: Phil Thornley <phil.jpthornley@gmail.com>
Subject: Re: Question about SPARK flow error.
Date: Sun, 20 Jun 2010 01:42:28 -0700 (PDT)
Date: 2010-06-20T01:42:28-07:00	[thread overview]
Message-ID: <4ba6c1f7-8471-46b9-b6ae-22489b34066e@e5g2000yqn.googlegroups.com> (raw)
In-Reply-To: 4c1d627f$0$3623$4d3efbfe@news.sover.net

On 20 June, 01:37, "Peter C. Chapin" <pcc482...@gmail.com> wrote:
> Phil Thornley wrote:
> > 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).
>
> Thanks for the suggestion. It sounds reasonable. What I did (at least for now)
> is more like a "junk initialization" although perhaps not complete junk. If
> the item is not found then Index gets Next_Index. So I started the procedure
> off with
>
>         Index := Next_Index;
>
> and removed that assignment from the condition when the item is not found. If
> the item is found inside the loop, Index gets overridden by a different
> value. Note that Next_Index is definitely initialized properly; my
> annotations declare it as a global in out variable and I have an
> initialization procedure (elsewhere) that sets it up.

That sounds like a reasonable solution in this case.

> I can see the danger to this... if I forgot to set Index inside the loop (or
> if that assignment gets removed later) the Examiner won't notice the problem.
> However, at least I can initialize Index to a semantically meaningful value.

I think that there is sometimes a tendency to expect more of the
Examiner than it can deliver - eliminating flow errors does not
guarantee correctness of the code, it just reduces the opportunities
for errors.

There may be some mileage in using check annotations to justify the
use of accept annotations for data flow errors - I'm going to think
about that one a little more.

Cheers,

Phil



      reply	other threads:[~2010-06-20  8:42 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
2010-06-20  0:37   ` Peter C. Chapin
2010-06-20  8:42     ` Phil Thornley [this message]
replies disabled

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