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] Account for observable alignments out of allocator


This patch introduces a way to parameterize what the Ada front-end
perceives of allocator alignments, which controls the use of the
make_aligning_type circuitry in gigi.

This improves efficiency overall and mitigates an issue we're having
with tagged types where we easily get to trigger at the allocation
site and mis-free on the deallocation site, when the views on the
involved type differ alignment-wise.

The tagged type issue is very visible on e.g. x86_64-linux where the
simple legal program below yields a number of legitimate glibc complaints
about bogus memory deallocation.

    with Ada.Unchecked_Deallocation;
    with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

    procedure Tagged_Alloc_Free is

      type Test_Base is tagged null record;
      type Test_Class_Access is access all Test_Base'Class;
      type Test_Extension is new Test_Base with record
	Last_Name : Unbounded_String := Null_Unbounded_String;
      end record;

      procedure Free is new Ada.Unchecked_Deallocation
	(Object => Test_Base'Class,
	 Name   => Test_Class_Access);

      Handle : Test_Class_Access := new Test_Extension;

    begin
      Free (Handle);
    end;

Tested on x86_64-suse-linux.

Olivier

2009-09-28  Olivier Hainque  <hainque@adacore.com>

	ada/
	* gcc-interface/targtyps.c (get_target_default_allocator_alignment):
	Account for observable alignments out of default allocators.

	testsuite/
	* gnat.dg (tagged_alloc_free.adb): New testcase.

Attachment: alloc.dif
Description: Text document


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