comp.lang.ada
 help / color / mirror / Atom feed
* Question Exception with Ada.Containers.Generic_Constrained_Array_Sort
@ 2012-08-13 20:05 awdorrin
  2012-08-13 20:44 ` awdorrin
  2012-08-14 12:39 ` Marc C
  0 siblings, 2 replies; 7+ messages in thread
From: awdorrin @ 2012-08-13 20:05 UTC (permalink / raw)




I had this code working, but today I started getting 'length check failed' exceptions.

I'm trying to implement a Generic_Constrained_Array_Sort to sort a slice of a constrained array.

Now I'm not sure if it is possible to pass a slice of the array into the constrained generic sort procedure.

Its possible I broke something somewhere else in the code that was related to this, but I haven't been able to track it down yet.

Here is what I'm trying to do:

procedure DXSort is new Ada.Containers.Generic_Constrained_Array_Sort(
  Index_Type   => Device_Index_Type,
  Element_Type => Device_Object_Type,
  Array_Type   => Device_Array_Type,
  "<"          => DevName_Less_Than);

With the following declarations:

  type Node_Rec_Type is private;
  type Node_Ptr_Type is access Node_Rec_Type;
  subtype Device_Object_Type is Node_Ptr_Type;
  subtype Device_Index_Type is Int32 range 1 .. 128;
  type Device_Array_Type is array(Device_Index_Type) of Device_Object_Type;

The comparison function is:

  function DevName_Less_Than( L,R : Device_Object_Type) return Boolean is
  begin
    if GetDeviceName(L) < GetDeviceName(R)
    then
      return TRUE;
    else
      return FALSE;
    end if;
  end DevName_Less_Than;

I make the call to the DXSort procedure with the following call:

  DXSort( DevList.DeviceList(1..DevList.Num_Devices) );
 
Num_Devices is always less than 128.

DevList is a record defined as:

  type DevListType is record
    Num_Devices : Int32;
    DeviceList  : Device_Array_Type;
  end record;

I thought that the issue might have to do with having 'Num_Devices' of type 'Int32' in the record, but defining the 'Device_Index_Type' subtype, but experimenting with changing the type still left me with 'length check failed'.

Any suggestions would be greatly appreciated! :)

-Al



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

end of thread, other threads:[~2012-08-17 21:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-13 20:05 Question Exception with Ada.Containers.Generic_Constrained_Array_Sort awdorrin
2012-08-13 20:44 ` awdorrin
2012-08-13 21:25   ` Adam Beneschan
2012-08-14 12:22     ` awdorrin
2012-08-14 12:39 ` Marc C
2012-08-15  7:11   ` Martin
2012-08-15 16:02     ` Georg Bauhaus

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