This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Deallocation of a single allocated object (PR ada/47880)


This change fixes a seg fault when a local storage pool has a single allocated
object, and Unchecked_Deallocation is used to deallocate that object.

The following test case must compile and execute quietly:

$ gnatmake -q pooltest
$ ./pooltest

with System.Pool_Local;
with Ada.Unchecked_Deallocation;
procedure pooltest is

   type Node;
   type Treenode is access Node;
   type Node is record
      Left  : Treenode := null;
      Right : Treenode := null;
      Item  : Integer  := 0; 
   end record;

   P : System.Pool_Local.Unbounded_Reclaim_Pool;    
   for Treenode'Storage_Pool use P;

   procedure Free is new Ada.Unchecked_Deallocation(Node, Treenode);
   TestNode : Treenode;
begin
   Testnode := new Node'(null, null, 1);
   Free(Testnode);   
end pooltest;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-04  Thomas Quinot  <quinot@adacore.com>

	PR ada/47880
	* s-pooloc.adb (Deallocate): Fix the case of deallocating the only
	allocated object.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]