comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: "accessibility check failed" on Node
Date: Thu, 27 Jun 2013 06:46:43 -0400
Date: 2013-06-27T06:46:43-04:00	[thread overview]
Message-ID: <85obarvnjg.fsf@stephe-leake.org> (raw)
In-Reply-To: kqfrrv$lsb$1@news2.open-news-network.org

Thomas Schmidt <TC.Schmidt@gmx.net> writes:

> I'm new to Ada. 

Welcome!

> Now what I don't understand: Why does "findNode1" work well while
> "findNode2" raises PROGRAM_ERROR at the line indicated below?

Accessibility refers to where an object is declared, relative to where
its type is declared.

> Given the following declarations:

It's better if you post a complete compilable example, so we can compile
it, and maybe fix the bug.


>   function findNode2
>     (graph : DirectedGraph;
>      aNode : access Node'Class)
>      return  Node_Class_Access is
>
>      position : constant NodeSets.Cursor :=
>        graph.nodes.Find (aNode.all'Access);	-- <<< Raises
> PROGRAM_ERROR with "accessibility check failed"

First, a style note: since aNode is already an access, aNode.all'Access
is just aNode. Is there some reason you wrote it this way?

The accessiblity check applies to the object that aNode designates. If
the type Node is declared at library level, but the object is at some
lower level in a subprogram, then when that subprogram returns, the
object will disappear, and the access value will become invalid. Ada
forbids this. 

If you post a complete example, we can give more precise help.

-- 
-- Stephe


      parent reply	other threads:[~2013-06-27 10:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-26 23:01 "accessibility check failed" on Node Thomas Schmidt
2013-06-26 23:45 ` Shark8
2013-06-26 23:58 ` Jeffrey Carter
2013-06-27  7:36 ` Georg Bauhaus
2013-06-27  7:49 ` Dmitry A. Kazakov
2013-06-27  8:24 ` Simon Wright
2013-06-27 11:19   ` Thomas Schmidt
2013-06-27 12:49     ` Frédéric Praca
2013-06-27 14:36     ` Eryndlia Mavourneen
2013-06-27 17:31       ` Jeffrey Carter
2013-06-27 17:45         ` Simon Wright
2013-06-27 23:26           ` Randy Brukardt
2013-06-28  0:52             ` Jeffrey Carter
2013-06-27 18:33         ` Eryndlia Mavourneen
2013-06-27 20:31           ` Jeffrey Carter
2013-06-27 23:29             ` Randy Brukardt
2013-06-27 14:51     ` Shark8
2013-06-27 17:29     ` Jeffrey Carter
2013-06-27 10:46 ` Stephen Leake [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