comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Hi-Lite high integrity showcase and overflow errors
Date: Mon, 03 Sep 2012 23:56:27 +0200
Date: 2012-09-03T23:56:27+02:00	[thread overview]
Message-ID: <5045278b$0$6576$9b4e6d93@newsspool3.arcor-online.net> (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;



             reply	other threads:[~2012-09-12  0:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-03 21:56 Georg Bauhaus [this message]
2012-09-04  2:53 ` Hi-Lite high integrity showcase and overflow errors 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
replies disabled

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