From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!paganini.bofh.team!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: GCC 11 bug? lawyer needed Date: Tue, 4 May 2021 22:54:43 -0500 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Wed, 5 May 2021 03:54:45 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="7752"; mail-complaints-to="news@jacob-sparre.dk" 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.7246 Xref: reader02.eternal-september.org comp.lang.ada:61954 List-Id: We spent a lot of time and effort in the ARG talking about this case (see AI12-0402-1). The Ada 2012 RM does indeed say this case is illegal. The reason is that aliased parameters are designed so that one can return part of of them in the return object of the function. And a normal parameter is assumed to be local (since its accessibility is unknown) - that means it is too local for an aliased parameter of a function that is used in some non-local way (including being returned from a non-local function). However, since one cannot return a part of a parameter for a function that returns an elementary type (other than anonymous access returns, which have special rules anyway), we added an exception to the rules for that case in Ada 202x. (We tried a number of more liberal exceptions, but they were complex and had [unlikely] holes.) So the most current rule is that the call of P is legal. That wasn't decided until the December ARG meeting, so it happened after the GNATPro 21 release (and I expect that the GNAT CE is derived from that version). And I'd guess that in Ada 2012 mode, this check would remain as it is (the change was not made retroactively - not sure why). Randy. "Simon Wright" wrote in message news:lyh7jjztor.fsf@pushface.org... > This code results in the error shown: > > 1. package Aliased_Tagged_Types is > 2. > 3. type T is tagged null record; > 4. > 5. function P (Param : aliased T) return Boolean > 6. is (False); > 7. > 8. function F (Param : T) return Boolean > 9. is (Param.P); > | > >>> actual for explicitly aliased formal is too short lived > > 10. > 11. end Aliased_Tagged_Types; > > The compiler code that results in this error is at sem_ch4.adb:1490, and > was introduced for Ada202x accessibiity checking reasons. > > -- Check whether the formal is aliased and if the accessibility > -- level of the actual is deeper than the accessibility level > -- of the enclosing subprogam to which the current return > -- statement applies. > > [...] > > if Is_Explicitly_Aliased (Form) > and then Is_Entity_Name (Act) > and then Static_Accessibility_Level > (Act, Zero_On_Dynamic_Level) > > Subprogram_Access_Level (Current_Subprogram) > then > Error_Msg_N ("actual for explicitly aliased formal is too" > & " short lived", Act); > end if; > > ---- > > For those interested, this issue affects Alire.