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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,58a33c3232e54ed3,start X-Google-Attributes: gid103376,public From: paul williams Subject: Why must access to unconstrained array statically match? Date: 1996/11/18 Message-ID: <3290EBC7.4065@itd.sterling.com>#1/1 X-Deja-AN: 197624076 content-type: text/plain; charset=us-ascii organization: Sterling Software mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.0 (WinNT; I) Date: 1996-11-18T00:00:00+00:00 List-Id: Given the following code sample: -------------------------------------------------------- package A is type An_Array is array (Positive range <>) of Integer; type An_Array_Ptr is access all An_Array; The_Array : aliased An_Array (1..10); The_Ptr : An_Array_Ptr := The_Array'Access; end A; -------------------------------------------------------- We get an error at compile time that says: "subtype of The_Array does not statically match designated subtype An_Array [RM_95 3.10.2(27)]" RM95 3.10.2 says: "...The view denoted by the prefix X shall satisfy the following additional requirements, presuming the expected type for X'Access is the general access type A: ... (27) ... if A's designated type is not tagged, then the type of the view shall be the same, and either A's designated subtype shall statically match the nominal subtype of the view, or the designated subtype shall be discriminated and unconstrained;" Sorry for the length of this, but can anyone tell me why this is prohibited? The designated subtype is unconstrained (An_Array), so why can't I get the pointer to an aliased view of a constrained variable? Does this have something to do with the restriction on discriminated records that the rationale mentions "which ensures that we cannot apply the Access attribute to a component that might disappear"? I don't get the connection. -- regards, paul "making the complex simple, that's creativity!" - unknown