comp.lang.ada
 help / color / mirror / Atom feed
From: artium@nihamkin.com
Subject: non-local pointer cannot point to local object
Date: Fri, 23 Feb 2018 00:54:26 -0800 (PST)
Date: 2018-02-23T00:54:26-08:00	[thread overview]
Message-ID: <15e8a72b-3644-4193-8947-b0aaf587c1c2@googlegroups.com> (raw)

I am cross costing a question from SO since it looks like all the Ada experts are here and not there :)

https://stackoverflow.com/questions/48939845/non-local-pointer-cannot-point-to-local-object


Can someone explain why I get "non-local pointer cannot point to local object" error, even though it looks like "Arr" and "Arr_Access" have the same accessibility level?

Can I overcome the problem without dynamically allocating memory and without using "Unchecked_Access"?


with Interfaces.C;
with Interfaces.C.Strings;

procedure X is

   type Integer_Access is access all Integer;

   Arr_Access : Interfaces.C.Strings.char_array_access;
   Arr : aliased Interfaces.C.char_array := Interfaces.C.To_C ("From");

   A : Integer_Access;
   I : aliased Integer := 6;

begin

   Arr_Access := Arr'Access;
   A := I'Access;

end X;



Thank you,
Artium

             reply	other threads:[~2018-02-23  8:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23  8:54 artium [this message]
2018-02-23  9:22 ` non-local pointer cannot point to local object J-P. Rosen
2018-02-24  8:13   ` gautier_niouzes
2018-02-23  9:42 ` Dmitry A. Kazakov
2018-02-23 12:19 ` AdaMagica
2018-02-23 16:56   ` Mehdi Saada
2018-02-23 17:16     ` Dmitry A. Kazakov
replies disabled

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