comp.lang.ada
 help / color / mirror / Atom feed
* GNAT Ada.Streams Bug?
@ 2004-11-25 17:41 Warren W. Gay VE3WWG
  2004-11-25 19:40 ` Jeff C r e e.m
  0 siblings, 1 reply; 12+ messages in thread
From: Warren W. Gay VE3WWG @ 2004-11-25 17:41 UTC (permalink / raw)


This is on gnat-3.14p on debian (debian's package library doesn't
seem to provide 3.15p), so this may be fixed by now:

I am running into a Ada.Streams problem with 24 bit values (3 bytes).
For example, if you use Ada.Streams to read in a partition table,
defined as follows, with 3.14p, you'll read more bytes than needed
(thus messing things up):

    type chs_t is mod 2**24;               -- Cylinder/Head/Sector
    for chs_t'size use 24;

    -- All other types below are 8, 16 or 32 bits wide

    type Partition_Type is
       record
          Flags :        part_flags_t;     -- Partition flags
          CHS_Start :    chs_t;            -- Cyl/Head/Sector Start
          Kind :         part_kind_t;      -- Partition Type
          CHS_End :      chs_t;            -- Cyl/Head/Sector End
          LBA_Start :    part_offset_t;    -- LBA Offset
          LBA_Size :     part_size_t;      -- LBA Size
       end record;

    for Partition_Type use
       record
          Flags          at 0 range 0..7;
          CHS_Start      at 1 range 0..23;
          Kind           at 4 range 0..7;
          CHS_End        at 5 range 0..23;
          LBA_Start      at 8 range 0..31;
          LBA_Size       at 12 range 0..31;
       end record;

    type Partition_Array is array(Natural range 1..4)
       of Partition_Type;

When Partition_Type'Read(Stream,Part_Table) didn't work correctly, I
put debugging statements into the 'Read routine, and
saw to my horror that the CHS_Start and CHS_End values are read in
as 4 byte values, instead of 3! So when chs_t'Read is called,
it wants STREAM_ELEMENT_ARRAY(1..4) filled, instead of the expected
1..3 slice.

Questions for the Group:

1. Can I assume this is a bug? (I am not a language lawyer)

2. Does anyone know if this has been fixed in gnat-3.15p or later?

It seems that if I stick to powers of 2 for data element sizes, things
work as expected. The work around is to divide up the chs_t type.

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-11-29 17:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-25 17:41 GNAT Ada.Streams Bug? Warren W. Gay VE3WWG
2004-11-25 19:40 ` Jeff C r e e.m
2004-11-26  4:11   ` Warren W. Gay VE3WWG
2004-11-26  9:49     ` Georg Bauhaus
2004-11-26 17:30       ` Warren W. Gay VE3WWG
2004-11-27  7:34         ` Martin Krischik
2004-11-28  1:10           ` Warren W. Gay VE3WWG
2004-11-29  7:50         ` tmoran
2004-11-29 17:47           ` Warren W. Gay VE3WWG
2004-11-26 22:47     ` Simon Wright
2004-11-27 14:42       ` Warren W. Gay VE3WWG
2004-11-27 17:25         ` Simon Wright

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