comp.lang.ada
 help / color / mirror / Atom feed
From: Stefan Lucks <lucks@th.informatik.uni-mannheim.de>
Subject: Re: Static vs dynamic evaluation anomaly?
Date: Fri, 9 Feb 2007 08:57:52 +0100
Date: 2007-02-09T08:57:52+01:00	[thread overview]
Message-ID: <Pine.LNX.4.58.0702090851070.9748@th.informatik.uni-mannheim.de> (raw)
In-Reply-To: <2cKyh.337215$FQ1.333812@attbi_s71>

On Thu, 8 Feb 2007, Jeffrey R. Carter wrote:

> Adam Beneschan wrote:
> > Hmmm.  This is certainly not the way I would expect a "perform this
> > check" or "don't perform this check" flag to work.  To me, if the
[...]
> I understand your logic; I'm not even saying I disagree. But perhaps the
> compiler writer's view is that it's OK to store the larger value as long
> as the extra bits are never used. Then the error is in the I/O, which is
> using the extra bits.

This is a valid point -- except that the extra bits are not just used by
the IO, but also, e.g., for comparisons:

with Ada.Text_IO;
use  Ada.Text_IO;
procedure test272 is
  type Six_Bits is mod 2**6;
  X: constant Six_Bits := 31;
  Z: constant Integer  := 31;
  T: integer;
begin
  for J in 0..9 loop
    T := (Integer(X) * 2**Integer(J)) mod Six_Bits'Modulus;
    Put (Integer 'Image         (J) &
         Six_Bits'Image  (X * 2**J) &
         Integer 'Image  (T)          );
    if (X * 2**J) = Six_Bits(T) then
      Put_Line(" equal");
    else
      Put_Line(" different!!!");
    end if;
  end loop;
end test272;

With "gnatmake" (no option) or "gnatmake -gnatp" I get wrong results:

./test272
 0 31 31 equal
 1 62 62 equal
 2 124 60 different!!!
 3 248 56 different!!!
 4 240 48 different!!!
 5 224 32 different!!!
 6 192 0 different!!!
 7 128 0 different!!!
 8 0 0 equal
 9 0 0 equal


-- 
Stefan Lucks      Th. Informatik, Univ. Mannheim, 68131 Mannheim, Germany
            e-mail: lucks@th.informatik.uni-mannheim.de
            home: http://th.informatik.uni-mannheim.de/people/lucks/
------  I  love  the  taste  of  Cryptanalysis  in  the  morning!  ------




  reply	other threads:[~2007-02-09  7:57 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <12shen4qjhv41a7@corp.supernews.com>
2007-02-06 19:17 ` Static vs dynamic evaluation anomaly? Jeffrey R. Carter
2007-02-06 20:01 ` Adam Beneschan
2007-02-06 20:15   ` Ludovic Brenta
2007-02-06 23:38     ` Matt.Jaffe
     [not found]     ` <12sipb529oilnab@corp.supernews.com>
2007-02-07 10:05       ` Ludovic Brenta
2007-02-07 21:54       ` Simon Wright
2007-02-09 12:39         ` GNAT's version Peter Hermann
2007-02-07  3:32   ` Static vs dynamic evaluation anomaly? Steve
2007-02-07 10:00     ` Ludovic Brenta
2007-02-07 10:21       ` Georg Bauhaus
2007-02-07 16:44         ` Adam Beneschan
2007-02-07 18:27           ` Jeffrey R. Carter
2007-02-07 18:55             ` Adam Beneschan
2007-02-07 21:52               ` Simon Wright
2007-02-08  0:48               ` Jeffrey R. Carter
2007-02-08  1:26                 ` Adam Beneschan
2007-02-08 18:44                   ` Jeffrey R. Carter
2007-02-09  7:57                     ` Stefan Lucks [this message]
2007-02-09 18:50                       ` Jeffrey R. Carter
2007-02-09 21:12                         ` Stefan Lucks
2007-02-10  5:22                           ` Jeffrey R. Carter
2007-02-10 12:29                             ` Ludovic Brenta
2007-02-08  6:57             ` Matt Jaffe
2007-02-08  9:01               ` Ludovic Brenta
2007-02-08 10:32                 ` Georg Bauhaus
2007-02-08 11:13                 ` Jean-Pierre Rosen
2007-02-08 13:02                   ` Ludovic Brenta
2007-02-07 21:46         ` Matt.Jaffe
2007-02-07  6:24   ` AW: " Grein, Christoph (Fa. ESG)
2007-02-07  6:59     ` Stefan Lucks
replies disabled

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