From: Serge Robyns <serge.robyns@gmail.com>
Subject: Issue with SPARK 2014
Date: Tue, 13 Oct 2015 10:37:06 -0700 (PDT)
Date: 2015-10-13T10:37:06-07:00 [thread overview]
Message-ID: <c4a5963b-78eb-4b55-83f5-a1de6b10717d@googlegroups.com> (raw)
I'm trying to use SPARK on a little game, so far only one error remains and I've no clue on how to fix this. I've been trying various approaches.
Here is the code snippet (hopefully complete enough).
Count1 : Natural range 0 .. Number_Of_Columns;
Count2 : Natural range 0 .. Number_Of_Columns;
J : Columns;
begin
Count1 := 0;
if Column > Columns'First then
for J in reverse Columns'First .. Columns'Pred (Column)
loop
pragma Loop_Variant ( Increases => Count1 );
pragma Loop_Variant ( Decreases => J );
pragma Loop_Invariant ( Count1 <= Integer (Columns'Pred (Column) - Columns'First) );
exit when The_Board.Board (Row, J) /= Player;
Count1 := Count1 + 1;
end loop;
end if;
Alternative:
Count2 := 0;
if Column < Columns'Last then
for J in Columns'Succ (Column) .. Columns'Last
loop
pragma Loop_Variant ( Increases => Count2 );
pragma Loop_Variant ( Increases => J );
pragma Loop_Invariant ( Count2 < Number_Of_Columns );
exit when The_Board.Board (Row, J) /= Player;
Count2 := Count2 + 1;
end loop;
end if;
I get similar errors on both:
medium: loop invariant might fail after first iteration, requires Count1 <= Columns'pred - 1
medium: loop invariant might fail after first iteration, requires Count2 < Number_Of_Columns
next reply other threads:[~2015-10-13 17:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-13 17:37 Serge Robyns [this message]
2015-10-13 20:40 ` Issue with SPARK 2014 joakimds
2015-10-14 15:25 ` Serge Robyns
2015-10-14 6:16 ` Simon Wright
2015-10-14 15:23 ` Serge Robyns
2015-10-14 20:04 ` Stuart
2015-10-15 8:44 ` Phil Thornley
2015-10-15 11:23 ` Stuart
2015-10-15 17:28 ` Serge Robyns
2015-10-18 8:44 ` Phil Thornley
2015-10-19 9:13 ` Serge Robyns
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox