comp.lang.ada
 help / color / mirror / Atom feed
* Problem with Gnat.Dynamic_Tables
@ 2002-07-09 23:04 achrist
  2002-07-11  0:19 ` achrist
  2002-07-11 15:13 ` Robert Dewar
  0 siblings, 2 replies; 10+ messages in thread
From: achrist @ 2002-07-09 23:04 UTC (permalink / raw)


I've got a problem with Gnat.Dynamic_Tables.  I want to use a dynamic
table of Ada.Strings.Unbounded.Unbounded_String data.  To do this I
use:
      
      package Csv_Table is new Gnat.Dynamic_Tables(
         Ada.Strings.Unbounded.Unbounded_String,
         Csv_Row_Index_Type,
         0, 1200, 100               
      );                           
       
      type Object is access all Csv_Table.Instance;

I set the size of the table with

      Csv_Table.Increment_Last( The_Table.all );

Before I assign to elements in the table, I check that the 
subscript is equal to Last.  This all works, but sometimes 
it crashes with a program error in the assignment:      

   procedure Add_Row (
         The_Table : in out Object; 
         New_Row   :        String  ) is 
   begin
      Csv_Table.Increment_Last( The_Table.all );
      The_Table.Table( Csv_Table.Last(The_Table.all) )
         := Ada.Strings.Unbounded.To_Unbounded_String(New_Row);
   end Add_Row;

The statement number that comes back from the crash is a-strunb.ads 368.
This is (gnat 3.14p1) the statement of the declaration of the 
Unbounded_String type.  I'm loading the data from a file, and the crash
happens around row 169 of my data, ie I get 168 values into the table
fine, then it crashes.  The crash happens in the statement that 
attempts to assign the unbounded string to the table entry.

I see in the Gnat.Dynamic_Tables comments that no initialization of
the array elements is done.  Does an unbounded_string need some
initialization?  If so, how can I make this work?

TIA for any help.


Al



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

end of thread, other threads:[~2002-07-12 23:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-09 23:04 Problem with Gnat.Dynamic_Tables achrist
2002-07-11  0:19 ` achrist
2002-07-11 15:13 ` Robert Dewar
2002-07-11 20:35   ` achrist
2002-07-12  3:42     ` Robert Dewar
2002-07-12  7:01       ` achrist
2002-07-12 14:23         ` Mats Weber
2002-07-12 16:56           ` achrist
2002-07-12 22:52             ` Mats Weber
2002-07-12 23:02               ` achrist

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