* Re: Static vs dynamic evaluation anomaly?
@ 2007-02-06 20:01 Adam Beneschan
2007-02-07 6:24 ` AW: " Grein, Christoph (Fa. ESG)
0 siblings, 1 reply; 3+ messages in thread
From: Adam Beneschan @ 2007-02-06 20:01 UTC (permalink / raw)
On Feb 6, 9:29 am, Matt Jaffe <jaf...@cableone.net> wrote:
> Any further help in explaining these anomalies would be much appreciated. (It's always possible we've stumbled across a compiler bug; but I am reluctant to come to that conclusion prematurely.)
I'm not so reluctant. It's a compiler bug.
The following program produces incorrect results on GNAT, or at least
on the version I'm using:
with Ada.Text_IO;
procedure test271 is
type Six_Bits is mod 2**6;
package Six_Bit_IO is new Ada.Text_IO.Modular_IO(Six_Bits);
X : Six_Bits := 31;
begin
for J in 0..5 loop
Ada.Text_IO.Put ("When J=" & Integer'image(J));
Ada.Text_IO.Put (", X*2**J =");
Six_Bit_IO.Put(X*2**J);
Ada.Text_IO.New_Line;
end loop;
end test271;
-- Adam
^ permalink raw reply [flat|nested] 3+ messages in thread
* AW: Static vs dynamic evaluation anomaly?
2007-02-06 20:01 Adam Beneschan
@ 2007-02-07 6:24 ` Grein, Christoph (Fa. ESG)
2007-02-07 6:59 ` Stefan Lucks
0 siblings, 1 reply; 3+ messages in thread
From: Grein, Christoph (Fa. ESG) @ 2007-02-07 6:24 UTC (permalink / raw)
To: Adam Beneschan, comp.lang.ada
No, this program is absolute correct. Modular types do not overflow,
they use modular arithmetic.
with Ada.Text_IO;
use Ada.Text_IO;
procedure test271 is
type Six_Bits is mod 2**6;
X: constant Six_Bits := 31;
Z: constant Integer := 31;
begin
for J in 0..5 loop
Put_Line (Integer 'Image (J) &
Six_Bits'Image (X * 2**J) &
Integer 'Image ((X * 2**J) mod Six_Bit'Modulus));
end loop;
end test271;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: AW: Static vs dynamic evaluation anomaly?
2007-02-07 6:24 ` AW: " Grein, Christoph (Fa. ESG)
@ 2007-02-07 6:59 ` Stefan Lucks
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Lucks @ 2007-02-07 6:59 UTC (permalink / raw)
There seems to be something wrong with the Put_Line statement:
On Wed, 7 Feb 2007, Grein, Christoph (Fa. ESG) wrote:
> with Ada.Text_IO;
> use Ada.Text_IO;
> procedure test271 is
> type Six_Bits is mod 2**6;
> X: constant Six_Bits := 31;
> Z: constant Integer := 31;
> begin
> for J in 0..5 loop
> Put_Line (Integer 'Image (J) &
> Six_Bits'Image (X * 2**J) &
> Integer 'Image ((X * 2**J) mod Six_Bit'Modulus));
Put_Line (Integer 'Image (J) &
Six_Bits'Image (X * 2**J) &
Integer 'Image ((Integer(X) * 2**Integer(J))
mod Six_Bits'Modulus)
);
> end loop;
> end test271;
>
--
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! ------
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-02-07 7:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <AEBEAAA73D5180469E2B3F071A96AC220110A637@sma2901.cr.eurocopter.corp>
2007-02-07 7:22 ` AW: Static vs dynamic evaluation anomaly? Grein, Christoph (Fa. ESG)
2007-02-06 20:01 Adam Beneschan
2007-02-07 6:24 ` AW: " Grein, Christoph (Fa. ESG)
2007-02-07 6:59 ` Stefan Lucks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox