From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Recommendation of safe subset of Ada to use? Date: Sun, 6 May 2018 09:43:09 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <9839db28-b6c6-44c9-9d36-336a39c12f25@googlegroups.com> <9a41b8a3-2ac9-4630-8028-2ba165b0fb0b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 6 May 2018 07:43:09 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="11a0a0180e2c5eaa0e443892b40677e3"; logging-data="15822"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LdF/VnbyetEqrDnHmclb0Zo1nMHu0hMs=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 In-Reply-To: <9a41b8a3-2ac9-4630-8028-2ba165b0fb0b@googlegroups.com> Content-Language: en-US Cancel-Lock: sha1:Ib2r9AASoBo/OiT93SezO+/XWSY= Xref: reader02.eternal-september.org comp.lang.ada:52028 Date: 2018-05-06T09:43:09+02:00 List-Id: 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. -- Jeff Carter "It is the German who is so uncourteous to his verbs." A Scandal in Bohemia 122