Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

America has been discovered before, but it has always been hushed up. -- Oscar Wilde


devel / comp.lang.ada / GCC 11 bug? lawyer needed

SubjectAuthor
* GCC 11 bug? lawyer neededSimon Wright
`* Re: GCC 11 bug? lawyer neededRandy Brukardt
 `* Re: GCC 11 bug? lawyer neededAdaMagica
  `* Re: GCC 11 bug? lawyer neededAdaMagica
   `* Re: GCC 11 bug? lawyer neededRandy Brukardt
    +- Re: GCC 11 bug? lawyer neededAdaMagica
    `* Re: GCC 11 bug? lawyer neededSimon Wright
     +- Re: GCC 11 bug? lawyer neededDmitry A. Kazakov
     `* Re: GCC 11 bug? lawyer neededRandy Brukardt
      `- Re: GCC 11 bug? lawyer neededSimon Wright

1
GCC 11 bug? lawyer needed

<lyh7jjztor.fsf@pushface.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5151&group=comp.lang.ada#5151

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: GCC 11 bug? lawyer needed
Date: Mon, 03 May 2021 17:08:20 +0100
Organization: Aioe.org NNTP Server
Lines: 40
Message-ID: <lyh7jjztor.fsf@pushface.org>
NNTP-Posting-Host: yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain
X-Complaints-To: abuse@aioe.org
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)
Cancel-Lock: sha1:ggy9NsvdAIhCs/mIBeV3RMQl5EM=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Simon Wright - Mon, 3 May 2021 16:08 UTC

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.

Re: GCC 11 bug? lawyer needed

<s6t4u4$7i8$1@franka.jacob-sparre.dk>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5156&group=comp.lang.ada#5156

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!paganini.bofh.team!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail
From: ran...@rrsoftware.com (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
Lines: 66
Message-ID: <s6t4u4$7i8$1@franka.jacob-sparre.dk>
References: <lyh7jjztor.fsf@pushface.org>
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
 by: Randy Brukardt - Wed, 5 May 2021 03:54 UTC

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" <simon@pushface.org> 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.

Re: GCC 11 bug? lawyer needed

<c58f6fc8-7955-40aa-a8d8-f53fe7f385een@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5157&group=comp.lang.ada#5157

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:4008:: with SMTP id h8mr29465275qko.366.1620208866930;
Wed, 05 May 2021 03:01:06 -0700 (PDT)
X-Received: by 2002:a25:c681:: with SMTP id k123mr42114450ybf.303.1620208866618;
Wed, 05 May 2021 03:01:06 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 5 May 2021 03:01:06 -0700 (PDT)
In-Reply-To: <s6t4u4$7i8$1@franka.jacob-sparre.dk>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.102.170; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.102.170
References: <lyh7jjztor.fsf@pushface.org> <s6t4u4$7i8$1@franka.jacob-sparre.dk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c58f6fc8-7955-40aa-a8d8-f53fe7f385een@googlegroups.com>
Subject: Re: GCC 11 bug? lawyer needed
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Wed, 05 May 2021 10:01:06 +0000
Content-Type: text/plain; charset="UTF-8"
 by: AdaMagica - Wed, 5 May 2021 10:01 UTC

Randy Brukardt schrieb am Mittwoch, 5. Mai 2021 um 05:54:46 UTC+2:
> 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

RM 3.10(9/3): Finally, a formal parameter or generic formal object of a tagged type is defined to be aliased.
RM 6.4.1(6/3): If the formal parameter is an explicitly aliased parameter, the type of the actual parameter shall be tagged or the actual parameter shall be an aliased view of an object.
Both of these conditions are fulfilled here.
There are many more places about explicitly aliased parameters in the RM. I've read them all. It left me wondering.

I do not see what aliasing a tagged parameter buys. A parameter of a tagged typed is aliased per se, or do I misread the RM.
I'm having big problems trying to understand the RM.
I will try to grock the AI.

Re: GCC 11 bug? lawyer needed

<aaa58296-3298-4b70-ac7e-1393f579f217n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5158&group=comp.lang.ada#5158

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a0c:e8c4:: with SMTP id m4mr31603820qvo.21.1620231002353;
Wed, 05 May 2021 09:10:02 -0700 (PDT)
X-Received: by 2002:a25:3241:: with SMTP id y62mr29172782yby.73.1620231002128;
Wed, 05 May 2021 09:10:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 5 May 2021 09:10:01 -0700 (PDT)
In-Reply-To: <c58f6fc8-7955-40aa-a8d8-f53fe7f385een@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.102.170; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.102.170
References: <lyh7jjztor.fsf@pushface.org> <s6t4u4$7i8$1@franka.jacob-sparre.dk>
<c58f6fc8-7955-40aa-a8d8-f53fe7f385een@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <aaa58296-3298-4b70-ac7e-1393f579f217n@googlegroups.com>
Subject: Re: GCC 11 bug? lawyer needed
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Wed, 05 May 2021 16:10:02 +0000
Content-Type: text/plain; charset="UTF-8"
 by: AdaMagica - Wed, 5 May 2021 16:10 UTC

AdaMagica schrieb am Mittwoch, 5. Mai 2021 um 12:01:07 UTC+2:
> I will try to grock the AI.
Hm, I'm still confused. Can anyone please come up with some examples that explain what this is all about?

Re: GCC 11 bug? lawyer needed

<s6vdrg$l09$1@franka.jacob-sparre.dk>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5160&group=comp.lang.ada#5160

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!paganini.bofh.team!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail
From: ran...@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: GCC 11 bug? lawyer needed
Date: Wed, 5 May 2021 19:39:11 -0500
Organization: JSA Research & Innovation
Lines: 73
Message-ID: <s6vdrg$l09$1@franka.jacob-sparre.dk>
References: <lyh7jjztor.fsf@pushface.org> <s6t4u4$7i8$1@franka.jacob-sparre.dk> <c58f6fc8-7955-40aa-a8d8-f53fe7f385een@googlegroups.com> <aaa58296-3298-4b70-ac7e-1393f579f217n@googlegroups.com>
Injection-Date: Thu, 6 May 2021 00:39:12 -0000 (UTC)
Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226";
logging-data="21513"; 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
 by: Randy Brukardt - Thu, 6 May 2021 00:39 UTC

"AdaMagica" <christ-usch.grein@t-online.de> wrote in message
news:aaa58296-3298-4b70-ac7e-1393f579f217n@googlegroups.com...
> AdaMagica schrieb am Mittwoch, 5. Mai 2021 um 12:01:07 UTC+2:
>> I will try to grock the AI.
> Hm, I'm still confused. Can anyone please come up with some examples that
> explain what this is all about?

See 6.4.1(6/3): there is an accessibility check on the actual parameter of
an aliased parameter. This allows an aliased parameter to have the
accessibility of the return object of a function, rather than local
accessibility. There's a bunch of rules in 3.10.2 that combine to have the
right effect.

You see the result in an operation like "Reference" in the containers. If
you have:

function Foo (A : in out Container; Idx : in Natural) return access
Element;

then an implementation of:

function Foo (A : in out Container) return access Element is
begin
return A.Data(Idx)'Access; -- (1)
end Foo;

(1) is illegal, as A has local to Foo accessibility, while the anonymous
access has the accessibility of the return object (the point of call), which
is necessarily outside of Foo.

You can change (1) to:
return A.Data(Idx)'Unchecked_Access; -- (1)
but now you can create a dangling pointer, for instance if Foo is assigned
to a library-level access type and the actual for A is not library-level.

But you can change the parameter to "aliased", then the accessibility check
is moved to the call site (where it must always suceeed for the vast
majority of calls). There's no accessibility check at (1) in that case
(which could be at best a dynamic check, which is a correctness hazard, and
also has an overhead cost). And you still have the safety of not being able
to create a dangling pointer.

It is a bit weird that this property is tied to "aliased" parameters. This
property came first, and we discussed the syntax to use for a long time.
Eventually it was decided to call them "aliased" parameters, but of course
that meant it was necessary to generalize the usages.

This special rule does have the downside of being able to fail in some safe
cases, like the one noted by the OP. That doesn't happen for procedures,
since aliased parameters have no special semantics for procedures. We
decided to remove the special semantics for functions for which it is
impossible to return a part of the parameter (that is, any
elementary-returning function), as that special semantics provides no
benefit in such a case (but it does have a cost).

I agree that the original author of that program should not have used
"aliased" in the way that they did (they don't need the special semantics),
but we realize that some people would prefer to *explicitly* mark things as
aliased when they are going to take 'Access (and not worry about the type of
the parameter -- after all, it could change). That is, they don't want to
depend on the implicit behavior of tagged types -- or perhaps they don't
even know about it. Which leads to the problem that occurs here, as
"aliased" has slightly different meanings for functions (now just composite
functions) and procedures.

Since this is real code that didn't work as expected, it seemed to make
sense to reduce the problem with a minor language tweak.

Randy.

Re: GCC 11 bug? lawyer needed

<9da72953-1c46-47fb-a013-6a01a0877f0dn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5161&group=comp.lang.ada#5161

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:a546:: with SMTP id o67mr3938502qke.160.1620306443939;
Thu, 06 May 2021 06:07:23 -0700 (PDT)
X-Received: by 2002:a25:3241:: with SMTP id y62mr5573389yby.73.1620306443749;
Thu, 06 May 2021 06:07:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 6 May 2021 06:07:23 -0700 (PDT)
In-Reply-To: <s6vdrg$l09$1@franka.jacob-sparre.dk>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.102.170; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.102.170
References: <lyh7jjztor.fsf@pushface.org> <s6t4u4$7i8$1@franka.jacob-sparre.dk>
<c58f6fc8-7955-40aa-a8d8-f53fe7f385een@googlegroups.com> <aaa58296-3298-4b70-ac7e-1393f579f217n@googlegroups.com>
<s6vdrg$l09$1@franka.jacob-sparre.dk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9da72953-1c46-47fb-a013-6a01a0877f0dn@googlegroups.com>
Subject: Re: GCC 11 bug? lawyer needed
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Thu, 06 May 2021 13:07:23 +0000
Content-Type: text/plain; charset="UTF-8"
 by: AdaMagica - Thu, 6 May 2021 13:07 UTC

Thank you, Randy, for the nice explanation. There're still some hazy places, but I begin to see the big picture.
Christoph

Re: GCC 11 bug? lawyer needed

<lylf8ry6j5.fsf@pushface.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5162&group=comp.lang.ada#5162

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: GCC 11 bug? lawyer needed
Date: Thu, 06 May 2021 21:02:54 +0100
Organization: Aioe.org NNTP Server
Lines: 37
Message-ID: <lylf8ry6j5.fsf@pushface.org>
References: <lyh7jjztor.fsf@pushface.org>
<s6t4u4$7i8$1@franka.jacob-sparre.dk>
<c58f6fc8-7955-40aa-a8d8-f53fe7f385een@googlegroups.com>
<aaa58296-3298-4b70-ac7e-1393f579f217n@googlegroups.com>
<s6vdrg$l09$1@franka.jacob-sparre.dk>
NNTP-Posting-Host: yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain
X-Complaints-To: abuse@aioe.org
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)
Cancel-Lock: sha1:D6cPxI+jcXzrMQKk9hhB32oQeO0=
X-Notice: Filtered by postfilter v. 0.9.2
 by: Simon Wright - Thu, 6 May 2021 20:02 UTC

"Randy Brukardt" <randy@rrsoftware.com> writes:

> I agree that the original author of that program should not have used
> "aliased" in the way that they did (they don't need the special semantics),
> but we realize that some people would prefer to *explicitly* mark things as
> aliased when they are going to take 'Access (and not worry about the type of
> the parameter -- after all, it could change). That is, they don't want to
> depend on the implicit behavior of tagged types -- or perhaps they don't
> even know about it. Which leads to the problem that occurs here, as
> "aliased" has slightly different meanings for functions (now just composite
> functions) and procedures.

The original code, from the Alire project, had (I've edited it slightly)

package Holders
is new Ada.Containers.Indefinite_Holders (Node'Class);

type Tree is
new Holders.Holder
and ...

function Root (This : Tree) return Node'Class is
(This.Constant_Reference);

where that Constant_Reference is inherited (eventually) from
Ada.Containers.Indefinite_Holders.Holder,

function Constant_Reference
(Container : aliased Holder) return Constant_Reference_Type;
pragma Inline (Constant_Reference);

Shame it had to be there.

I've just tried splattering 'aliased' wherever the compiler told me it
was needed; it's now spreading into other packages. Ugh.

The solution might just be using composition rather than inheritance.

Re: GCC 11 bug? lawyer needed

<s71ksr$v8k$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5163&group=comp.lang.ada#5163

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: GCC 11 bug? lawyer needed
Date: Thu, 6 May 2021 22:51:43 +0200
Organization: Aioe.org NNTP Server
Lines: 60
Message-ID: <s71ksr$v8k$1@gioia.aioe.org>
References: <lyh7jjztor.fsf@pushface.org>
<s6t4u4$7i8$1@franka.jacob-sparre.dk>
<c58f6fc8-7955-40aa-a8d8-f53fe7f385een@googlegroups.com>
<aaa58296-3298-4b70-ac7e-1393f579f217n@googlegroups.com>
<s6vdrg$l09$1@franka.jacob-sparre.dk> <lylf8ry6j5.fsf@pushface.org>
NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Thu, 6 May 2021 20:51 UTC

On 2021-05-06 22:02, Simon Wright wrote:
> "Randy Brukardt" <randy@rrsoftware.com> writes:
>
>> I agree that the original author of that program should not have used
>> "aliased" in the way that they did (they don't need the special semantics),
>> but we realize that some people would prefer to *explicitly* mark things as
>> aliased when they are going to take 'Access (and not worry about the type of
>> the parameter -- after all, it could change). That is, they don't want to
>> depend on the implicit behavior of tagged types -- or perhaps they don't
>> even know about it. Which leads to the problem that occurs here, as
>> "aliased" has slightly different meanings for functions (now just composite
>> functions) and procedures.
>
> The original code, from the Alire project, had (I've edited it slightly)
>
> package Holders
> is new Ada.Containers.Indefinite_Holders (Node'Class);
>
> type Tree is
> new Holders.Holder
> and ...
>
> function Root (This : Tree) return Node'Class is
> (This.Constant_Reference);
>
> where that Constant_Reference is inherited (eventually) from
> Ada.Containers.Indefinite_Holders.Holder,
>
> function Constant_Reference
> (Container : aliased Holder) return Constant_Reference_Type;
> pragma Inline (Constant_Reference);
>
> Shame it had to be there.
>
> I've just tried splattering 'aliased' wherever the compiler told me it
> was needed; it's now spreading into other packages. Ugh.
>
> The solution might just be using composition rather than inheritance.

In my experience mixing handles with target types does not work anyway
regardless accessibility rules mess.

I tend to use interfaces instead:

type Abstract_Node_Interface is interface ...;

Then both the handle and the target type implement
Abstract_Node_Interface. The target type goes into hiding, the client
need not to see it.

This requires manual delegation in all primitive operations of handles:
dereference + call. But in the end it pays off. Especially with trees,
because in mutator operations I can check the reference count of the
node and choose to clone it (and maybe the subtree) if there are
multiple external handles to it.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: GCC 11 bug? lawyer needed

<s71vt1$9ug$1@franka.jacob-sparre.dk>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5164&group=comp.lang.ada#5164

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!paganini.bofh.team!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail
From: ran...@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: GCC 11 bug? lawyer needed
Date: Thu, 6 May 2021 18:59:28 -0500
Organization: JSA Research & Innovation
Lines: 67
Message-ID: <s71vt1$9ug$1@franka.jacob-sparre.dk>
References: <lyh7jjztor.fsf@pushface.org><s6t4u4$7i8$1@franka.jacob-sparre.dk><c58f6fc8-7955-40aa-a8d8-f53fe7f385een@googlegroups.com><aaa58296-3298-4b70-ac7e-1393f579f217n@googlegroups.com><s6vdrg$l09$1@franka.jacob-sparre.dk> <lylf8ry6j5.fsf@pushface.org>
Injection-Date: Thu, 6 May 2021 23:59:29 -0000 (UTC)
Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226";
logging-data="10192"; 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
 by: Randy Brukardt - Thu, 6 May 2021 23:59 UTC

"Simon Wright" <simon@pushface.org> wrote in message
news:lylf8ry6j5.fsf@pushface.org...
> "Randy Brukardt" <randy@rrsoftware.com> writes:
>
>> I agree that the original author of that program should not have used
>> "aliased" in the way that they did (they don't need the special
>> semantics),
>> but we realize that some people would prefer to *explicitly* mark things
>> as
>> aliased when they are going to take 'Access (and not worry about the type
>> of
>> the parameter -- after all, it could change). That is, they don't want to
>> depend on the implicit behavior of tagged types -- or perhaps they don't
>> even know about it. Which leads to the problem that occurs here, as
>> "aliased" has slightly different meanings for functions (now just
>> composite
>> functions) and procedures.
>
> The original code, from the Alire project, had (I've edited it slightly)
>
> package Holders
> is new Ada.Containers.Indefinite_Holders (Node'Class);
>
> type Tree is
> new Holders.Holder
> and ...
>
> function Root (This : Tree) return Node'Class is
> (This.Constant_Reference);
>
> where that Constant_Reference is inherited (eventually) from
> Ada.Containers.Indefinite_Holders.Holder,
>
> function Constant_Reference
> (Container : aliased Holder) return Constant_Reference_Type;
> pragma Inline (Constant_Reference);
>
> Shame it had to be there.

Constant_Reference is the case for which these semantics was designed. Hard
to avoid it there. ;-)

Note that by returning Node'Class rather than an elementary type, you don't
get to use the new rule tweak. Since all tagged types are by-reference (not
by copy), the "Root" routine has to return the object that it has, which
ultimately is part of Tree. So you actually need "aliased" on Root, since
you are (ultimately) returning a part of the formal parameter (and which
could become dangling if you pass in an object which is too local).

> I've just tried splattering 'aliased' wherever the compiler told me it
> was needed; it's now spreading into other packages. Ugh.

I think you need to make a copy of the return object somewhere; the obvious
answer is to replace function Constant_Reference with function Element. Of
course, if the return object is large enough, that could be expensive. (That
doesn't work if you want to write the node, but the use of
Constant_Reference doesn't allow that anyway, so in this case it doesn't
matter.)

> The solution might just be using composition rather than inheritance.

Yeah, or using handles more as Dmitry says. In any case, it seems like some
redesign is necessary.

Randy.

Re: GCC 11 bug? lawyer needed

<lyv97tjzrl.fsf@pushface.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=5166&group=comp.lang.ada#5166

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!aioe.org!yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: GCC 11 bug? lawyer needed
Date: Sat, 08 May 2021 11:17:18 +0100
Organization: Aioe.org NNTP Server
Lines: 7
Message-ID: <lyv97tjzrl.fsf@pushface.org>
References: <lyh7jjztor.fsf@pushface.org>
<s6t4u4$7i8$1@franka.jacob-sparre.dk>
<c58f6fc8-7955-40aa-a8d8-f53fe7f385een@googlegroups.com>
<aaa58296-3298-4b70-ac7e-1393f579f217n@googlegroups.com>
<s6vdrg$l09$1@franka.jacob-sparre.dk> <lylf8ry6j5.fsf@pushface.org>
<s71vt1$9ug$1@franka.jacob-sparre.dk>
NNTP-Posting-Host: yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain
X-Complaints-To: abuse@aioe.org
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:hQr51MRErPTOY0xM14pjtFG/C1g=
 by: Simon Wright - Sat, 8 May 2021 10:17 UTC

"Randy Brukardt" <randy@rrsoftware.com> writes:

> I think you need to make a copy of the return object somewhere; the
> obvious answer is to replace function Constant_Reference with function
> Element.

That appears to be a fine workround! Thanks!

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor