comp.lang.ada
 help / color / mirror / Atom feed
* using 'storage_size ?
@ 2003-10-12  7:37 Alex Xela
  2003-10-12 12:34 ` Duncan Sands
  2003-10-12 23:24 ` Robert I. Eachus
  0 siblings, 2 replies; 7+ messages in thread
From: Alex Xela @ 2003-10-12  7:37 UTC (permalink / raw)


When the line 20 of the following code is uncommented the program raises a
Storage_Error with GNAT3.15p under W2k.

If I did not make a mistake, I reclaim for  5Mo at line 23. This is
confusing me?????



---------------

with ada.text_io,Unchecked_Deallocation,Ada.Exceptions;
procedure garbage is
   ko : constant := 1024;
   Mo : constant := ko*ko;
   type byte is range 0..255; for Byte'size use 8;
   type tab_byte is array(positive range <>) of byte; pragma pack(tab_byte);
   type ptr_Tab is access tab_byte;
   ptr1,ptr2 : ptr_tab;
   procedure free is new
Unchecked_Deallocation(Object=>tab_byte,name=>ptr_tab);
begin
   ada.text_io.put_line(" Garbage : begin ");
   for i in 1..10 loop
      ptr1 := new tab_byte'(positive'first..5*Mo=>255);
   end loop;
   ptr2 := new tab_byte'(positive'first..5*Mo=>255);
   ada.text_io.put_line("
  Ptr2.all'size ->"&integer'image(ptr2.all'size/(mo*8))&" Mo");
   ada.text_io.put_line("
  Ptr1.all'size ->"&integer'image(ptr1.all'size/(mo*8))&" Mo");
   declare
      type local_ptr is access tab_byte;
      for local_ptr'storage_size use Mo*8;--[line 20]GNAT 3.15p raised
STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW
      ptr3 : local_ptr;
   begin
      ptr3 := new tab_byte'(positive'first..5*Mo=>255);--line 23
      ada.text_io.put_line("
  Ptr3.all'size ->"&integer'image(ptr3.all'size/(mo*8))&" Mo");
   end ;
   free(ptr1);
   free(ptr2);
   ada.text_io.put_line(" Garbage : end ");
end garbage;










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

end of thread, other threads:[~2003-10-13 18:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-12  7:37 using 'storage_size ? Alex Xela
2003-10-12 12:34 ` Duncan Sands
2003-10-12 14:12   ` Alex Xela
2003-10-12 18:23     ` Duncan Sands
2003-10-12 23:24 ` Robert I. Eachus
2003-10-13 18:20   ` Alex Xela
2003-10-13 18:53     ` Robert I. Eachus

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