Named return values in C++ doesn't work ?

Gabriel Dos Reis
Wed Sep 30 11:29:00 GMT 1998

>>>>>  Sylvain Pion <> wrote:

> On Tue, Sep 29, 1998 at 12:22:57PM -0700, Mike Stump wrote:
>> > Also, it's a pity (as written in the doc) that we can't specify the
>> > exact location of the constructor.  Is someone working on
>> > implementing such a feature ?
>> ?  I can't guess what you mean.

> The constructor of the returned object must be at the beginning of the
> function (before any code), if you want to use the "named return value"
> extension.  But I would like it to be after some instruction.

> Precisely, I refer to the following comment in the gcc doc:
> "The disadvantage of this extension is that you do not control when the
> default constructor for the return value is called: it is always called at the
> beginning."

> However, I'd first like this feature to work (maybe it's my fault, but the
> simple example I gave doesn't work).

Well this optimization is a GNU extension. The Standard does allow it
in a more uniform way. Personnally I think the GNU extension
equivalent should be dropped (or deprecated) in favor of the Standard

-- Gaby

More information about the Gcc mailing list