comp.lang.ada
 help / color / mirror / Atom feed
* SPARK - runtime checks question
@ 2009-06-19 15:26 Maciej Sobczak
  2009-06-19 15:31 ` Maciej Sobczak
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Maciej Sobczak @ 2009-06-19 15:26 UTC (permalink / raw)


Consider the following:

-- my_package.ads:
package My_Package is
   function Distance (X : in Natural; Y : in Natural) return Natural;
end My_Package;

-- my_package.adb:
package body My_Package is

   function Distance (X : in Natural; Y : in Natural) return Natural
   is
      Result : Natural;
   begin
      if X > Y then
         Result := X - Y;    // line 8
      else
         Result := Y - X;    // line 10
      end if;
      return Result;
   end Distance;

end My_Package;

The Distance function is supposed to compute the distance between two
Naturals.

I have a problem with rtc checks that are generated for line 8 and 10.
After running spark -vcg, sparksimp and pogs, the spark.sum file
contains this:

VCs for function_distance :
----------------------------------------------------------------------------
      |       |                     |  -----Proved In-----  |
|       |
 #    | From  | To                  | vcg | siv | plg | prv | False |
TO DO |
----------------------------------------------------------------------------
 1    | start | rtc check @ 8       |     |     |     |     |       |
YES  |
 2    | start | rtc check @ 10      |     |     |     |     |       |
YES  |
 3    | start |    assert @ finish  |     | YES |     |     |
|       |
 4    | start |    assert @ finish  |     | YES |     |     |
|       |
----------------------------------------------------------------------------

and of course 50% of VCs are undischarged in the final report.

As far as I understand the math, the relevant values are always within
the target type. What am I missing in this simple example?

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com

Database Access Library for Ada: www.inspirel.com/soci-ada



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-06-19 21:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-19 15:26 SPARK - runtime checks question Maciej Sobczak
2009-06-19 15:31 ` Maciej Sobczak
2009-06-19 16:04 ` Rod Chapman
2009-06-19 18:29   ` Adam Beneschan
2009-06-19 18:55     ` Rod Chapman
2009-06-19 21:38   ` Maciej Sobczak
2009-06-19 18:33 ` Adam Beneschan
2009-06-19 21:16   ` Maciej Sobczak

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