comp.lang.ada
 help / color / mirror / Atom feed
From: Zheng Liu <zheng.liu@space.gc.ca>
Subject: Problem with SGI ADA95 1.2
Date: 1999/06/02
Date: 1999-06-02T00:00:00+00:00	[thread overview]
Message-ID: <37554199.E8EDE1CE@space.gc.ca> (raw)

I am having a problem to assign values to a bit-packed Boolean array
using the following program. The compiler I used is SGI ADA95 Release
1.2. In this
program, I declaraed a record that contains a packed Boolean array with
all its
elements inilialized to False. When I was trying to set the first
element to True,
the program sets the 2nd, the 4th and the 6th elements to True instead.
The first
element remains False.

Does anybody have an idea why this is happenning?


-- test bit-packed boolean variable assignment

with Text_Io;

procedure Bit_Test1 is

   package Bool_Io is new Text_IO.Enumeration_Io(Boolean);
   use Bool_Io;
   package Int1_Io is new Text_Io.Integer_Io(Integer);

    type Bool_Array_type is array ( 1 .. 9 ) of Boolean;
    pragma Pack ( Bool_Array_Type);
    Bool_Array : Bool_Array_Type := (others => False);

    type Test_Record_Type is
      record
         Bool_Array : Bool_Array_Type := ( others => False);
         Spare : Integer range 0 .. 65535 := 0;
      end Record;
    for Test_Record_Type use
       record
        Bool_Array at 0 range 0 .. 8;
        Spare at 2 range 0 ..15;
       end record;

    Test_Record : Test_Record_Type;

    Test_Word : Integer range 0 .. 155;
    for Test_Word'Size use 8;
    for Test_Word use at Test_Record'Address;

  begin

    Test_Record.Bool_Array(1) := true;
    Text_Io.Put_Line("test_record bool 1 ");
    Put(Test_Record.Bool_Array(1));
    Text_Io.New_Line;
    Text_Io.Put_Line("test_record bool 2 ");
    Put(Test_Record.Bool_Array(2));
    Text_Io.New_Line;
    Text_Io.Put_Line("test_record bool 3 ");
    Put(Test_Record.Bool_Array(3));
    Text_Io.New_Line;
    Text_Io.Put_Line("test_record bool 4 ");
    Put(Test_Record.Bool_Array(4));
    Text_Io.New_Line;
    Text_Io.Put_Line("test_record bool 5 ");
    Put(Test_Record.Bool_Array(5));
    Text_Io.New_Line;
    Text_Io.Put_Line("test_record bool 6 ");
    Put(Test_Record.Bool_Array(6));
    Text_Io.New_Line;
    Text_Io.Put_Line("test_record bool 7 ");
    Put(Test_Record.Bool_Array(7));
    Text_Io.New_Line;
    Text_Io.Put_Line("test_record bool 8 ");
    Put(Test_Record.Bool_Array(8));
    Text_Io.New_Line;
    Text_Io.Put_Line("test_record bool 9 ");
    Put(Test_Record.Bool_Array(9));
    Text_Io.New_Line;
    Text_Io.Put_Line("spare");
    Int1_Io.Put(Test_Record.Spare);
    Text_Io.New_Line;
    Text_Io.Put_Line("Test_Word");
    Int1_Io.Put(Test_Word);

end Bit_Test1;





             reply	other threads:[~1999-06-02  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-02  0:00 Zheng Liu [this message]
1999-06-02  0:00 ` Problem with SGI ADA95 1.2 David C. Hoos, Sr.
1999-06-02  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