From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,233f0e04e488a4a2 X-Google-Attributes: gid103376,public From: Simon Pilgrim Subject: Re: Size of 0..255 is not 8 bits? Date: 1998/05/14 Message-ID: <355B94D0.4812@gecm.com>#1/1 X-Deja-AN: 353368970 Content-Transfer-Encoding: 7bit References: <355A436E.11F76529@cl.cam.ac.uk> <355AEA1D.6C292667@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: GEC Marconi Avionics Newsgroups: comp.lang.ada Date: 1998-05-14T00:00:00+00:00 List-Id: Robert Dewar wrote: > > < 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