From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9dcaa9f073e2ef8f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!v11g2000prk.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Type in allocator has deeper level than designated class-wide type Date: Mon, 13 Jun 2011 18:08:03 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1e38ede5-7df3-46d5-836e-f48cec87628e@v11g2000prk.googlegroups.com> References: <9bf2ef73-5cc7-4863-90d7-2e2cf3bcd294@o10g2000prn.googlegroups.com> <92fb5bf2-f43e-4ac9-97eb-6092f10e5607@e17g2000prj.googlegroups.com> <9eddf7db-7f7d-4872-b597-bb0c5bddc50f@x38g2000pri.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1308013684 18090 127.0.0.1 (14 Jun 2011 01:08:04 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 14 Jun 2011 01:08:04 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v11g2000prk.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:20775 Date: 2011-06-13T18:08:03-07:00 List-Id: On Jun 13, 5:49=A0pm, Adrian Hoe wrote: > On Jun 14, 1:11=A0am, Adam Beneschan wrote: > > > > > > > On Jun 13, 8:31=A0am, Adrian Hoe wrote: > > > > Hi all, > > > > I have stomped into above error and I am stuck with the error and > > > runtime exception PROGRAM_ERROR : accessibility check failed. > > > > Here's the fragment of my codes: > > > > generic > > > =A0 =A0N : Positive; > > > =A0 =A0type Item is private; > > > package High_Cloud is > > > > =A0 =A0package List renames Heterogeneous_Doubly_Link_List; > > > =A0 =A0use List; > > > > =A0 =A0type Data_Array =A0 =A0 =A0 =A0 =A0 =A0 =A0 is array ( 1 .. N = ) of Item; > > > > =A0 =A0type Element_Record =A0 =A0 =A0 =A0 =A0 is new List.Node with = private; > > > =A0 =A0type Series_Access =A0 =A0 =A0 =A0 =A0 =A0is new List.Access_L= ist; > > > > private > > > > =A0 =A0type Element_Record is new List.Node with > > > =A0 =A0 =A0 record > > > =A0 =A0 =A0 =A0 =A0Name =A0 =A0 =A0 =A0 =A0 : Unbounded_String; > > > =A0 =A0 =A0 =A0 =A0Color =A0 =A0 =A0 =A0 =A0: Unbounded_String; > > > =A0 =A0 =A0 =A0 =A0Data =A0 =A0 =A0 =A0 =A0 : Data_Array; > > > =A0 =A0 =A0 end record; > > > > ... > > > end High_Cloud; > > > > In the package body of High_Cloud, I have a procedure: > > > > =A0 =A0procedure Add > > > =A0 =A0 =A0 ( Cloud =A0 =A0 =A0 =A0 =A0: in out High_Cloud_Record; > > > =A0 =A0 =A0 =A0 Name =A0 =A0 =A0 =A0 =A0 =A0: in =A0 =A0 Unbounded_St= ring; > > > =A0 =A0 =A0 =A0 Color =A0 =A0 =A0 =A0 =A0 : in =A0 =A0 Unbounded_Stri= ng; > > > =A0 =A0 =A0 =A0 Data =A0 =A0 =A0 =A0 =A0 =A0: in =A0 =A0 Data_Array ) > > > =A0 =A0is > > > > =A0 =A0 =A0 New_Element : List.Access_Node; > > > > =A0 =A0begin > > > > =A0 =A0 =A0 New_Element :=3D new Element_Record' > > > <=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Error/Warning here. > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ( Constructor.Init ( = Name, Color, Data) ) ; > > > > =A0 =A0 =A0 Concatenate ( Cloud.Series, New_Element ) ; > > > > =A0 =A0end Add; > > > > My intention is to use genericity to create a data which is an array > > > (1..N) of any_type. This data is then stored in a list. Procedure Add > > > instantiate (by calling to Constructor.Init) the list's node with > > > data. > > > > I have read the ARM 3.10.2 and 3.10.1 and also John Barnes book yet I > > > still have no clue how to solve the problem. > > > > Can you please help? Thanks. > > > I think we need to see the definition of Constructor.Init, at least. > > (I'm guessing that Heterogeneous_Doubly_Link_List is a library package > > that defines Node as a tagged record and Access_Node as "access all > > Node'Class". =A0But I don't have a guess about what Init is.) > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Adam > > Yes, you are right. In Heterogeneous_Doubly_Link_List: > > =A0 =A0type List =A0 =A0 =A0 =A0is limited private; > =A0 =A0type Access_List is access List; > > =A0 =A0type Node =A0 =A0 =A0 =A0 =A0 is tagged private; > =A0 =A0type Access_Node =A0 is access all Node'Class; > > private > > =A0 =A0type Node is tagged record > =A0 =A0 =A0 Previous : Access_Node; > =A0 =A0 =A0 Next =A0 =A0 : Access_Node; > =A0 =A0end record; > > =A0 =A0type List is limited record > =A0 =A0 =A0 Head =A0 =A0: Access_Node :=3D null; > =A0 =A0 =A0 Tail =A0 =A0: Access_Node :=3D null; > =A0 =A0 =A0 Current : Access_Node :=3D null; > =A0 =A0 =A0 Count =A0 : Unsigned :=3D 0; > =A0 =A0end record; > > And: > > =A0 =A0package body Constructor is > > =A0 =A0 =A0 function Init > =A0 =A0 =A0 =A0 =A0( New_Name =A0: Unbounded_String; > =A0 =A0 =A0 =A0 =A0 =A0New_Color : Unbounded_String; > =A0 =A0 =A0 =A0 =A0 =A0New_Data =A0: Data_Array ) > =A0 =A0 =A0 return Element_Record is > =A0 =A0 =A0 begin > =A0 =A0 =A0 =A0 =A0return ( List.Constructor.Init > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0with > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Name =A0=3D> New_Name, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Color =3D> New_Color, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Data =A0=3D> New_Data > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ) ; > =A0 =A0 =A0 end Init; > > =A0 =A0end Constructor; > > Is the problem lying in the Data : Data_Array in Element_Record or in > the return statement of Constructor.Init? Where is the above Constructor package defined? Is it directly within High_Cloud, or is it defined inside a subprogram in the body of High_Cloud? Assuming it's the former, I can't get either our compiler or GNAT (4.5.2) to generate an error or warning message. However, I don't know if any relevant rules about accessibility have changed in Ada 2012. I'd have to study this one further. If you're not using our compiler or GNAT, and it's an Ada 2005 compiler, it could well be an error in your compiler. -- Adam