comp.lang.ada
 help / color / mirror / Atom feed
From: ncohen@watson.ibm.com (Norman H. Cohen)
Subject: Re: Ada 9X question: accessibility
Date: 15 Nov 1994 13:57:42 GMT
Date: 1994-11-15T13:57:42+00:00	[thread overview]
Message-ID: <3aaeom$qn9@watnews1.watson.ibm.com> (raw)
In-Reply-To: CzA7v5.KIJ@inmet.camb.inmet.com

In article <CzA7v5.KIJ@inmet.camb.inmet.com>, stt@spock.camb.inmet.com
(Tucker Taft) writes: 

|> As you guessed, it makes no difference where Ptr_2 is declared,
|> what matters is where its type is declared.  In the new terminology,
|> the accessibility level of Int_2 is statically deeper than
|> the accessibility level of Access_Integer_Type, so the 'Access
|> is illegal.

It would be helpful to explain why the rule must be based on the depth of
the variable's type rather than on the depth of the variable itself:  A
value stored in a local variable of a global access type can be assigned
to a global variable of the same type, thus creating a dangling
reference.

     procedure Example is
        type Outer_Access_Type is access all Integer;
        Outer_Variable: Outer_Access_Type;
     begin
        declare
           Inner_Variable : Outer_Access_Type;
           Target         : aliased Integer;
        begin
           Inner_Variable := Target'Access;  -- ILLEGAL!
           Outer_Variable := Inner_Variable;
        end;
        Outer_Variable.all := Outer_Variable.all + 1;  -- dangling reference
     end Example;

--
Norman H. Cohen    ncohen@watson.ibm.com



      reply	other threads:[~1994-11-15 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-11-11 19:47 Ada 9X question: accessibility There can be only one
1994-11-14 23:57 ` Tucker Taft
1994-11-15 13:57   ` Norman H. Cohen [this message]
replies disabled

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