comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Warning: accessibility check failure with GNAT GPL 2013
Date: Wed, 30 Oct 2013 20:28:31 -0500
Date: 2013-10-30T20:28:31-05:00	[thread overview]
Message-ID: <l4sbo0$6v4$1@loke.gir.dk> (raw)
In-Reply-To: m8uj6pxbsxrh$.1jwxgyor2dhw8$.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:m8uj6pxbsxrh$.1jwxgyor2dhw8$.dlg@40tude.net...
> On Mon, 28 Oct 2013 08:23:40 -0700 (PDT), sangomarco@gmail.com wrote:
>
>> Thanks for your quick response. I don't have enough experience with Ada,
>> please could you tell me more about the rule? I don't understand why this
>> is not allow.
>
> It is allowed, unfortunately. That is why you have got only warning, not 
> an
> error. Unfortunately, because it does not make sense in 90% of cases in
> practice.
>
>> My goal is to create a main task which makes a successor
>> tasks if necessarry. And, since I cannot use the sybtype mak to create a
>> new task in the current execution of a main task body as the following
>> declaration
>
> Use a named access type instead. E.g.
>
>   type Cyclic_Thread_Ptr is access all Cyclic_Thread:
>
> Informally, "new" adapts to the expected access type. So does the 
> anonymous
> access type from its side. When both meet each other there is no
> information available to determine the scope where the allocated object
> would live. The language rules use the most conservative estimation of 
> that
> scope (the body of the subprogram), which in practice never corresponds to
> the programmer's intent. The resulting accessibility check necessarily
> fails at run time. Be glad you were warned by the compiler.

This is true in Ada 2005, but those rules were completely redone for Ada 
2012, and those make it more likely that this will in fact work as expected. 
(Most of the static checks were removed.) OTOH, I still think your advice is 
a good idea, because no human can actually figure out what the accessibility 
of an anonymous access return will be. :-) So you can drive yourself nuts if 
it doesn't work for some reason.

                           Randy.


      parent reply	other threads:[~2013-10-31  1:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-28 13:49 Warning: accessibility check failure with GNAT GPL 2013 sangomarco
2013-10-28 14:26 ` Dmitry A. Kazakov
2013-10-28 15:23   ` sangomarco
2013-10-28 15:49     ` Dmitry A. Kazakov
2013-10-28 16:05       ` sangomarco
2013-10-28 16:13       ` Georg Bauhaus
2013-10-28 17:31         ` Adam Beneschan
2013-10-31  1:28       ` Randy Brukardt [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