comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Where to get Zero Footprint Profile?
Date: Sun, 25 May 2014 20:39:16 -0400
Date: 2014-05-25T20:39:16-04:00	[thread overview]
Message-ID: <wcclhtpmkzv.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: f18842d0-9cb5-4c8b-8377-9941534764a7@googlegroups.com

droiddermo@gmail.com writes:

> ...For example I don't quite understand what is secondary stack
> and what it is used for.

The secondary stack is used for caller-unknown-sized function results.
That is, function results that are of indefinite subtype.
For example, if you have:

    function F(...) return String is
        Length: Natural := ...; -- who knows what?
        Result: String(1..Length) := (others => 'A');
    begin
        return Result;
    end F;

Then somewhere else:

    X: constant String := F(...);

then F will return its result on the secondary stack.
The caller (declaration of X) doesn't know the size of the
result of F.  So F allocates its result on the secondary stack,
and then returns the address of that result to the caller.

You can look at s-secsta.ad[sb] to see how it works by default.

If the result subtype of F were "subtype S is String(1..80);",
then it would not use the secondary stack.

- Bob

  parent reply	other threads:[~2014-05-26  0:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-24 18:00 Where to get Zero Footprint Profile? droiddermo
2014-05-24 18:50 ` ake.ragnar.dahlgren
2014-05-25  8:39   ` droiddermo
2014-05-25 14:25     ` Luke A. Guest
2014-05-25 18:42       ` droiddermo
2014-05-25 19:34         ` Luke A. Guest
2014-05-26  0:39         ` Robert A Duff [this message]
2014-05-26  8:26         ` Brian Drummond
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox