comp.lang.ada
 help / color / mirror / Atom feed
* Hi-Lite high integrity showcase and overflow errors
@ 2012-09-03 21:56 Georg Bauhaus
  2012-09-04  2:53 ` Shark8
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Georg Bauhaus @ 2012-09-03 21:56 UTC (permalink / raw)


http://www.open-do.org/projects/hi-lite/a-lighter-introduction-to-hi-lite/
introduces AdaCore's new proof tools. This introduction makes me worry
about integrity, pardon me.

I have included the procedure Mult from the example, after correcting
it as suggested by the text. Mult should perform saturating arithmetic.

The high integrity example program fails miserably. (C programmers
should have a good laugh.)

The program compiles without any warnings. It also behaves as
instructed, but not as intended, I suppose. It either terminates
with an overflow check failure, or with a range check failure,
depending on whether GNAT was run in Ada mode (-gnato), or in GNAT mode.

So to ask a provocative question, what is the use of all these tools
if they still lead to programs that overflow so easily?

Or am I just incorrectly assuming thing and X * Y will make the tools
complain fiercely about possible overflow?

Or that this is just an example procedure and the real Mult and Add will
of course use suitable algorithms for testing the feasibility of the
arithmetical operations?


procedure Alicebob is

    type My_Int is range 0 .. 10_000;

    function Mult (X , Y : My_Int) return My_Int is
    begin
       if X * Y < 10_000 then
          return X * Y;
       else
          return 10_000;
       end if;
    end Mult;

begin
    if Mult (1000, 33) /= 10_000 then
       raise Program_Error;
    end if;
end Alicebob;



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

end of thread, other threads:[~2012-10-03 10:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-03 21:56 Hi-Lite high integrity showcase and overflow errors Georg Bauhaus
2012-09-04  2:53 ` Shark8
2012-09-04  3:05   ` Shark8
2012-09-04  8:30     ` Georg Bauhaus
2012-09-04 18:45       ` Shark8
2012-09-04 20:21 ` Florian Weimer
2012-09-04 21:24   ` Shark8
2012-09-05  9:25   ` yannick.moy
2012-09-05  9:19 ` yannick.moy
2012-09-05 11:15   ` Georg Bauhaus
2012-10-03 10:47   ` Florian Weimer

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