"Simon Belmont" <
[email protected]> wrote in message news:
[email protected]...
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.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)