From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Recommendation of safe subset of Ada to use?
Date: Sun, 6 May 2018 11:45:53 +0300
Date: 2018-05-06T11:45:53+03:00 [thread overview]
Message-ID: <fl7tm1F45i3U1@mid.individual.net> (raw)
In-Reply-To: <pcmbmd$fee$1@dont-email.me>
On 18-05-06 10:43 , Jeffrey R. Carter wrote:
> On 05/05/2018 11:32 PM, gorgelo@hotmail.com wrote:
>>> with Ada.Text_IO; use Ada.Text_IO;
>>>
>>> procedure jdoodle is
>>> type Integer_Access is access all Integer;
>>> function Inner(Value : aliased in out Integer) return
>>> Integer_Access is
>>> begin
>>> return Value'Access;
>>> end Inner;
>>> function Outer return Integer_Access is
>>> Value : aliased Integer := 0;
>>> begin
>>> return Inner(Value);
>>> end Outer;
>>> Ptr : Integer_Access := Outer; -- !!! Dangling reference
>>> begin
>>> Put_Line("Hello World");
>>> end jdoodle;
>
> This seems to violate ARM 3.10.2(29): the accessibility level of Value
> (the object passed by reference to Inner) is deeper than that of the
> access type Integer_Access. I cannot find an exception to this for
> aliased parameters.
My GNAT complains:
> gcc -c -g -gnat12 jdoodle.adb
jdoodle.adb:8:16: non-local pointer cannot point to local object
gnatmake: "jdoodle.adb" compilation error
However, this is GNAT GPL 2012 (don't ask me why I still use this...)
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
next prev parent reply other threads:[~2018-05-06 8:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-05 21:23 Recommendation of safe subset of Ada to use? joakimds
2018-05-05 21:32 ` gorgelo
2018-05-06 7:43 ` Jeffrey R. Carter
2018-05-06 8:45 ` Niklas Holsti [this message]
2018-05-06 8:52 ` gorgelo
2018-05-06 13:15 ` Jere
2018-05-06 13:47 ` Jere
2018-05-06 21:28 ` Brad Moore
2018-05-08 0:19 ` Randy Brukardt
2018-05-08 8:07 ` Simon Wright
2018-05-07 15:54 ` onox
2018-05-08 0:22 ` Randy Brukardt
2018-05-08 0:06 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox