Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

As Will Rogers would have said, "There is no such things as a free variable."


devel / comp.lang.ada / Re: Is this legal?

SubjectAuthor
* Is this legal?Simon Belmont
+- Re: Is this legal?Gautier write-only address
+* Re: Is this legal?AdaMagica
|`* Re: Is this legal?Simon Belmont
| `- Re: Is this legal?AdaMagica
`- Re: Is this legal?Randy Brukardt

1
Is this legal?

<6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com>

 copy mid

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

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:1a28:: with SMTP id bk40mr6929572qkb.224.1634410818981;
Sat, 16 Oct 2021 12:00:18 -0700 (PDT)
X-Received: by 2002:a25:81d1:: with SMTP id n17mr21182390ybm.425.1634410818770;
Sat, 16 Oct 2021 12:00:18 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sat, 16 Oct 2021 12:00:18 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=159.250.202.227; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy
NNTP-Posting-Host: 159.250.202.227
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com>
Subject: Is this legal?
From: sbelmont...@gmail.com (Simon Belmont)
Injection-Date: Sat, 16 Oct 2021 19:00:18 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 38
 by: Simon Belmont - Sat, 16 Oct 2021 19:00 UTC

I'm trying to learn the 2012 changes to accessibility rules, e.g. aliased parameters, additional dynamics checks, and some eliminated unnecessary typecasts. But I am also aware of the....fluid nature of GNATs correctness of implementing them, and the following situation seems dubious. In particular, when 'current' is an anonymous access type, it compiles without issue, but not when it's a named access type (or when explicitly converted to one). Does anyone know off hand which is the correct behavior?

Thanks
-sb

procedure Main is

subtype str5 is string(1..5);
type s5_ptr is access all str5;

type T is
record
current : access str5;
--current : s5_ptr; -- "aliased actual has wrong accessibility"
foo : aliased str5;
end record;

function F (y : aliased in out str5) return access str5 is
begin
return y'Access;
end F;


procedure P (x : in out T) is
begin
x.current := F(x.foo);
end P;

o : T := (current => null, foo => "Hello");

begin
P(o);
end Main;

Re: Is this legal?

<7b331577-8ba6-4852-a416-947ef80f1aa2n@googlegroups.com>

 copy mid

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

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:6214:2307:: with SMTP id gc7mr20009997qvb.34.1634459723180;
Sun, 17 Oct 2021 01:35:23 -0700 (PDT)
X-Received: by 2002:a25:d47:: with SMTP id 68mr22590817ybn.204.1634459722936;
Sun, 17 Oct 2021 01:35:22 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sun, 17 Oct 2021 01:35:22 -0700 (PDT)
In-Reply-To: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1206:4596:5040:4928:b3d3:cf9a:d40b;
posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG
NNTP-Posting-Host: 2a02:1206:4596:5040:4928:b3d3:cf9a:d40b
References: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7b331577-8ba6-4852-a416-947ef80f1aa2n@googlegroups.com>
Subject: Re: Is this legal?
From: gautier_...@hotmail.com (Gautier write-only address)
Injection-Date: Sun, 17 Oct 2021 08:35:23 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 0
 by: Gautier write-only a - Sun, 17 Oct 2021 08:35 UTC

For information, ObjectAda v.10.2 accepts both variants (in Ada 2012 mode).

Re: Is this legal?

<54181867-ea8d-4fdf-8a5c-dcd167421e79n@googlegroups.com>

 copy mid

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

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:1754:: with SMTP id l20mr24049240qtk.309.1634460075673;
Sun, 17 Oct 2021 01:41:15 -0700 (PDT)
X-Received: by 2002:a25:4d83:: with SMTP id a125mr6451701ybb.277.1634460075366;
Sun, 17 Oct 2021 01:41:15 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sun, 17 Oct 2021 01:41:15 -0700 (PDT)
In-Reply-To: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.101.123; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.101.123
References: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <54181867-ea8d-4fdf-8a5c-dcd167421e79n@googlegroups.com>
Subject: Re: Is this legal?
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Sun, 17 Oct 2021 08:41:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 32
 by: AdaMagica - Sun, 17 Oct 2021 08:41 UTC

> procedure Main is
>
> subtype str5 is string(1..5);
> type s5_ptr is access all str5;

Ptr: s5_ptr;

> type T is
> record
> --current : access str5;
> current : s5_ptr; -- "aliased actual has wrong accessibility"
> foo : aliased str5;
> end record;

The accessibility rules are far too complicated and unreadable (I'm not about trying to grock them), but the component current has a type that has a lifetime as long as Main. Your object o may be declared in an inner scope with less lifetime. Thus the assignment must be illegal.

begin
declare
o : T := (Acurrent => null, --Ncurrent => null,
foo => "Hello");
begin
P (o);
--Ptr := o.Ncurrent; -- global point to disappearing object
Ptr := o.Acurrent; -- global point to disappearing object
end;
put_line(Ptr.all); -- prints Hello
end Main;

But it occurs to me that GNAT CE 2021 has a problem here. (Comment out all occurrences of Ncurrent.)

Re: Is this legal?

<31fd07c2-f604-4c52-9b72-fd26a12c9cbdn@googlegroups.com>

 copy mid

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

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:1e06:: with SMTP id n6mr25323335qtl.365.1634495483567;
Sun, 17 Oct 2021 11:31:23 -0700 (PDT)
X-Received: by 2002:a05:6902:114a:: with SMTP id p10mr26229303ybu.91.1634495483467;
Sun, 17 Oct 2021 11:31:23 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sun, 17 Oct 2021 11:31:23 -0700 (PDT)
In-Reply-To: <54181867-ea8d-4fdf-8a5c-dcd167421e79n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=159.250.202.227; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy
NNTP-Posting-Host: 159.250.202.227
References: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com> <54181867-ea8d-4fdf-8a5c-dcd167421e79n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <31fd07c2-f604-4c52-9b72-fd26a12c9cbdn@googlegroups.com>
Subject: Re: Is this legal?
From: sbelmont...@gmail.com (Simon Belmont)
Injection-Date: Sun, 17 Oct 2021 18:31:23 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 24
 by: Simon Belmont - Sun, 17 Oct 2021 18:31 UTC

On Sunday, October 17, 2021 at 4:41:17 AM UTC-4, AdaMagica wrote:

> The accessibility rules are far too complicated and unreadable (I'm not about trying to grock them), but the component current has a type that has a lifetime as long as Main. Your object o may be declared in an inner scope with less lifetime. Thus the assignment must be illegal.

I only ask because there are two rules, one that says the scope of the object must be *statically* deeper than the return type of the function to be legal, but then another similar one down the page that says a runtime check is made to ensure it (which begs the question of why the runtime check is needed if it must be done statically). Normally things like that are for edge cases with anonymous access types, so it's not immediately obvious (to me, at least) if GNAT is blowing the static check or the dynamic check (Or both? Or neither?)

6.4.1~6.3/3
In a function call, the accessibility level of the actual object for each explicitly aliased parameter shall not be statically deeper than the accessibility level of the master of the call (see 3.10.2).

6.4.1~15.1/3
In a function call, for each explicitly aliased parameter, a check is made that the accessibility level of the master of the actual object is not deeper than that of the master of the call (see 3.10.2).

Re: Is this legal?

<f8bee95a-ba66-4253-b8cd-32e6a15d499dn@googlegroups.com>

 copy mid

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

 copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5f91:: with SMTP id j17mr29158893qta.138.1634554227517;
Mon, 18 Oct 2021 03:50:27 -0700 (PDT)
X-Received: by 2002:a5b:846:: with SMTP id v6mr26771768ybq.457.1634554227414;
Mon, 18 Oct 2021 03:50:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 18 Oct 2021 03:50:27 -0700 (PDT)
In-Reply-To: <31fd07c2-f604-4c52-9b72-fd26a12c9cbdn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=94.31.101.123; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf
NNTP-Posting-Host: 94.31.101.123
References: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com>
<54181867-ea8d-4fdf-8a5c-dcd167421e79n@googlegroups.com> <31fd07c2-f604-4c52-9b72-fd26a12c9cbdn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f8bee95a-ba66-4253-b8cd-32e6a15d499dn@googlegroups.com>
Subject: Re: Is this legal?
From: christ-u...@t-online.de (AdaMagica)
Injection-Date: Mon, 18 Oct 2021 10:50:27 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 0
 by: AdaMagica - Mon, 18 Oct 2021 10:50 UTC

may be the code is legal, but definitly dynamic accessibility checks should be present (which must fail in the last example)..

Re: Is this legal?

<sklfau$h0t$1@franka.jacob-sparre.dk>

 copy mid

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

 copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!paganini.bofh.team!newsfeed.xs3.de!callisto.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: Is this legal?
Date: Mon, 18 Oct 2021 22:50:52 -0500
Organization: JSA Research & Innovation
Lines: 43
Message-ID: <sklfau$h0t$1@franka.jacob-sparre.dk>
References: <6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com>
Injection-Date: Tue, 19 Oct 2021 03:50:54 -0000 (UTC)
Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226";
logging-data="17437"; 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 - Tue, 19 Oct 2021 03:50 UTC

"Simon Belmont" <sbelmont700@gmail.com> wrote in message
news:6c49980a-fe55-4cea-a356-d021b417d942n@googlegroups.com...
>I'm trying to learn the 2012 changes to accessibility rules, ...
....
>Does anyone know off hand which is the correct behavior?

I can assure you that no one anywhere will *ever* know "off-hand" the
correct behavior. :-) It takes quite a bit of looking to be sure.

....
....
> function F (y : aliased in out str5) return access str5 is
> begin
> return y'Access;
> end F;

This is always legal (we hope :-). There should be a static (or dynamic)
check on Y when F is called that Y has an appropriate lifetime for the
result. (I can't grok "accessibility", either. I always think in terms of
lifetimes, and then try to translate to the wording.)

> procedure P (x : in out T) is
> begin
> x.current := F(x.foo);
> end P;

This should always be statically illegal. X here has the lifetime of P (as
the actual lifetime is unknown). That's not long enough regardless of how
you declare Current (since it's type is necessarily outside of P). There is
no special accessibility rules for anonymous access components (unlike most
other cases); they always have the accessibility (think lifetime) of the
enclosing type.

My understanding is that AdaCore has been actively working on
re-implementing these rules correctly, and in a few cases we've changed the
rules as it was obvious that a better rule was possible (so Ada 2022 changes
this some more). But none of the Ada 2022 changes should change this
example.

Randy.

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor