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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeds.phibee-telecom.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!gegeweb.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Thick bindings to a C library and gnattest: suggestions? Date: Tue, 2 Jul 2013 10:58:56 +0200 Organization: cbb software GmbH Message-ID: <1j12cco498mvw.5a4cc7rrd293.dlg@40tude.net> References: <1fxsf70zl2ckq.aysy7d9c8jkl$.dlg@40tude.net> <93fc7ff5-73b2-455a-85ae-3f3505144de2@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: IenaDxMXK2hi7fvYcb+MlQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 1975 Xref: number.nntp.dca.giganews.com comp.lang.ada:182206 Date: 2013-07-02T10:58:56+02:00 List-Id: 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