comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Limited type in generic package causes double free or corruption
Date: Wed, 28 Sep 2016 12:51:04 -0700
Date: 2016-09-28T12:51:04-07:00	[thread overview]
Message-ID: <nsh6v3$nr5$1@dont-email.me> (raw)
In-Reply-To: <bbd1a304-0349-4e79-a712-7a6ac36ec156@googlegroups.com>

On 09/28/2016 11:41 AM, onox wrote:
> 
> Then I get (with -gnat2012) this:
> 
>>>> (Ada 2005) cannot copy object of a limited type (RM-2005 6.5(5.5/2))
>>>> return by reference not permitted in Ada 2005
> 
> The error seems to refer to a paragraph in the RM that has been deleted in RM-2012. See
http://www.adaic.org/resources/add_content/standards/12aarm/html/AA-6-5.html
item 5.6/3 and 5.c/3.

I expected an error, though this is not a very useful message. The referenced
paragraph in the ARM for ISO/IEC 8652:2007 reads, "If the result subtype of the
function is limited, then the expression of the return statement (if any) shall
be an aggregate, a function call (or equivalent use of an operator), or a
qualified_expression or parenthesized expression whose operand is one of these."

> 5.6/3 refers to section 7.5
(http://www.adaic.org/resources/add_content/standards/12aarm/html/AA-7-5.html).
If I understand 2.9/3 in section 7.5 correctly, my current code should be
allowed (which may explain why it does compile in GNAT 2016 according to Anh Vo).

No, 2.9 says that the expression of an expression function that returns a
limited type must be something allowed by 2.1: basically an aggregate or
function call. Your expression function's expression is an object, which is not
allowed. I think you have discovered a GNAT error in compiling expression
functions that return a limited type.

> If Tree is tagged (which it is), doesn't that mean Ada uses
> copy-by-reference
instead of copy-by-value. Or am I mixing things up here?

You are confused, though I'm not sure about what. Since Tree is limited, it
cannot be copied.

-- 
Jeff Carter
"Brave Sir Robin ran away."
Monty Python and the Holy Grail
59


  reply	other threads:[~2016-09-28 19:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 13:25 Limited type in generic package causes double free or corruption onox
2016-09-28 16:06 ` Dmitry A. Kazakov
2016-09-28 16:20 ` Jeffrey R. Carter
2016-09-28 18:41   ` onox
2016-09-28 19:51     ` Jeffrey R. Carter [this message]
2016-09-29  8:12     ` Alejandro R. Mosteo
2016-09-28 17:27 ` Anh Vo
2016-09-28 17:34 ` AdaMagica
2016-09-28 21:42   ` 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