comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Thick bindings to a C library and gnattest: suggestions?
Date: Tue, 2 Jul 2013 10:58:56 +0200
Date: 2013-07-02T10:58:56+02:00	[thread overview]
Message-ID: <1j12cco498mvw.5a4cc7rrd293.dlg@40tude.net> (raw)
In-Reply-To: 93fc7ff5-73b2-455a-85ae-3f3505144de2@googlegroups.com

On Tue, 2 Jul 2013 01:33:04 -0700 (PDT), Maurizio Tomasi wrote:

> When I compile this program, both occurrences of "A (A'First)'Access" in
> Read_Vector and Write_Vector make GNAT complain:

Replace

   A (A'First)'Access

with

   A (A'First)'Unchecked_Access

> I do not understand what causes this problem: in both cases the address of
> A's first element is not stored in a global variable but used as the
> argument to a procedure call. So how can this be a "non-local pointer"?

The type Pointer is declared in the scope outer to the object (indexed
subprogram's argument) the pointer is supposed to point.

The rule is that the scope of a pointer type should not be wider than the
scope of the object, which statically prevents dangling pointers. In the
cases like yours, you know better than the compiler, so you just tell him
to back off. This is what Unchecked_Access is for.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2013-07-02  8:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01  9:02 Thick bindings to a C library and gnattest: suggestions? ziotom78
2013-07-01  9:45 ` Dmitry A. Kazakov
2013-07-01 11:11   ` Maurizio Tomasi
2013-07-01 11:41     ` Simon Wright
2013-07-01 12:00       ` Maurizio Tomasi
2013-07-01 12:42         ` Dmitry A. Kazakov
2013-07-01 19:07           ` Simon Wright
2013-07-01 12:32     ` Dmitry A. Kazakov
2013-07-01 12:41       ` Maurizio Tomasi
2013-07-01 12:47       ` Simon Wright
2013-07-02  8:55     ` Georg Bauhaus
2013-07-02  8:33   ` Maurizio Tomasi
2013-07-02  8:58     ` Dmitry A. Kazakov [this message]
2013-07-02 16:58     ` Robert A Duff
2013-07-02 17:00     ` Jeffrey Carter
2013-07-01 17:16 ` Jeffrey Carter
2013-07-02  4:24   ` Randy Brukardt
2013-07-02  4:37     ` Shark8
2013-07-02  5:04     ` tmoran
2013-07-02 22:27       ` Randy Brukardt
2013-07-03 12:02   ` Jacob Sparre Andersen
2013-07-02  3:16 ` Jerry
2013-07-02  4:02   ` Shark8
replies disabled

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