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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!news.ecp.fr!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Warning: accessibility check failure with GNAT GPL 2013 Date: Wed, 30 Oct 2013 20:28:31 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <4395468b-93d3-45f4-8bc0-91cd646ff1d9@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1383182912 7140 69.95.181.76 (31 Oct 2013 01:28:32 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 31 Oct 2013 01:28:32 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:17564 Date: 2013-10-30T20:28:31-05:00 List-Id: "Dmitry A. Kazakov" 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.