comp.lang.ada
 help / color / mirror / Atom feed
From: nblanpain@hotmail.com
Subject: Re: Aliased
Date: 16 Jun 2005 07:03:09 -0700
Date: 2005-06-16T07:03:09-07:00	[thread overview]
Message-ID: <1118930589.514028.150340@g47g2000cwa.googlegroups.com> (raw)
In-Reply-To: PcOdnUT7y5Tjcy3fRVn-uw@comcast.com

So this is my sources and the compilation error :

------ Container.ads
generic
   type T_Item is private;
   Static_Size : Integer;
package Container is
   type T_Array is array (Integer range <>) of T_Item;
   type A_Array is access all T_Array;
   type T_Container is tagged record
      Obj_Array : aliased T_Array (1..Static_Size);
      Ptr_Array : A_Array;
   end record;
   procedure Initialize (This : in out T_Container; Dynamic_Size : in
Integer);
   function P_Array (This : in T_Container) return A_Array;
end Container;

------ Container.adb
package body Container is
   procedure Initialize (This : in out T_Container; Dynamic_Size : in
Integer) is
   begin
      if Dynamic_Size /= 0 then
         This.Ptr_Array := new T_Array (1.. Dynamic_Size);
     elsif Static_Size /= 0 then
        This.Ptr_Array := This.Obj_Array'Access; --- Compilation Error
     end if;
   end Initialize;
   function P_Array (This : in T_Container) return A_Array is
   begin
      return This.Ptr_Array;
   end P_Array;
end Container;

-- Compilation Error : Object subtype must statically match designated
subtype. No local pointer cannot point to local object.

I have tried to solve this problem using Unchecked_Access or To_Pointer
of System. I have found no solution.
Have you a solution to my problem?

Thanks,




  reply	other threads:[~2005-06-16 14:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-15 16:06 Aliased nblanpain
2005-06-15 16:35 ` Aliased Martin Dowie
2005-06-15 18:56 ` Aliased nblanpain
2005-06-15 21:47   ` Aliased Martin Dowie
2005-06-16  3:15 ` Aliased Steve
2005-06-16 14:03   ` nblanpain [this message]
2005-06-16 19:56     ` Aliased Simon Wright
2005-06-17  7:01       ` Aliased nblanpain
2005-06-17  9:38         ` Aliased Larry Kilgallen
2005-06-19 19:44           ` Aliased nblanpain
2005-06-19 20:33             ` Aliased Jeffrey Carter
2005-06-20  9:34               ` Aliased nblanpain
2005-06-20 16:41                 ` Aliased Jeffrey Carter
2005-06-17  2:15     ` Aliased Jeffrey Carter
2005-06-17  7:02       ` Aliased nblanpain
2005-06-17  2:35     ` Aliased Steve
2005-06-17  7:52       ` Aliased Dmitry A. Kazakov
2005-06-17  4:38     ` Aliased Christoph Grein
2005-06-29 21:10     ` Aliased Robert A Duff
replies disabled

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