From: Simon Pilgrim <simon.pilgrim@gecm.com>
Subject: Re: Size of 0..255 is not 8 bits?
Date: 1998/05/14
Date: 1998-05-14T00:00:00+00:00 [thread overview]
Message-ID: <355B94D0.4812@gecm.com> (raw)
In-Reply-To: dewar.895191407@merv
Robert Dewar wrote:
>
> <<This did not change anything, V is still a 16-bit integer. I get
> no difference whether the 'Size clause is for the type, the object,
> both or none at all. Only
> >>
>
> It is indeed a bug in a compiler if a Size clause for an object does not
> result in the object tkaing the indicated nnumber of bits. But perhaps
> you had better post the EXACT code that leads you to that conclusion.
After reading one of your posts in another thread on 'size, I took
Markus' code and added some lines to display the sizes:
----------------------------------
with Ada.Text_IO.Text_Streams, Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO.Text_Streams, Ada.Text_IO, Ada.Integer_Text_IO;
procedure Strange2 is
type ValueType is range 0..255;
for ValueType'Object_Size use 8;
V: ValueType;
begin
Put (" ValueType'last:");
Put (Integer(ValueType'last));
New_line;
Put (" ValueType'size:");
Put (Integer(ValueType'size));
New_line;
Put (" ValueType'object_size:");
Put (Integer(ValueType'object_size));
New_line;
Put (" V'size:");
Put (Integer(V'size));
New_line;
for X in 1..5 loop
ValueType'Read(Stream(Standard_Input), V);
Put(Integer(V));
end loop;
end Strange2;
----------------------------------
I compiled and ran this with GNAT 3.10p on WinNT4 and got the following:
>echo ABCDEFGHIJKLMNOP | ./strange2
ValueType'last: 255
ValueType'size: 8
ValueType'object_size: 8
V'size: 8
65 67 69 71 73
This appears to be reading 8 bit chunks from the stream, but every other
byte.
If I changed the range of ValueType to 0..127 and rebuilt, I got the
following:
>echo ABCDEFGHIJKLMNOP | ./strange2
ValueType'last: 127
ValueType'size: 7
ValueType'object_size: 8
V'size: 8
65 66 67 68 69
This works as I expect.
Regards,
Simon Pilgrim
next prev parent reply other threads:[~1998-05-14 0:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-05-14 0:00 Size of 0..255 is not 8 bits? Markus Kuhn
1998-05-13 0:00 ` Matthew Heaney
1998-05-14 0:00 ` Markus Kuhn
1998-05-14 0:00 ` John McCabe
1998-05-14 0:00 ` Robert Dewar
1998-05-14 0:00 ` Robert Dewar
1998-05-14 0:00 ` Simon Pilgrim [this message]
1998-05-15 0:00 ` Markus Kuhn
1998-05-15 0:00 ` Samuel T. Harris
1998-05-15 0:00 ` Tucker Taft
1998-05-15 0:00 ` Joe Gwinn
1998-05-16 0:00 ` Robert Dewar
1998-05-17 0:00 ` Joe Gwinn
1998-05-14 0:00 ` Tom Moran
1998-05-14 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox