From -353005662928228064
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,f5d433881cc29cff
X-Google-Attributes: gidf78e5,public
From: James Kanze <james-albert.kanze@vx.cit.alcatel.fr>
Subject: Re: Named return value optimisation- reprise.
Date: 1997/06/19
Message-ID: <rf5oh92n8wo.fsf@vx.cit.alcatel.fr>#1/1
X-Deja-AN: 251130513
References: <33a345bf.7425526@news.ipswich.gil.com.au> <33A478C1.329@acm.org> <u9pvtnuemu.fsf@yorick.cygnus.com> <33a5f9a1.5157214@news.ipswich.gil.com.au> <u9k9jsuawy.fsf@yorick.cygnus.com>
X-Original-Date: 19 Jun 1997 13:12:39 +0200
Organization: -
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBM6lZoUy4NqrwXLNJAQG1lQH8C4VzKj3vvKK5PEw6B/tEnWU2rRbV5DLy +tTX3L+0peGkMCmBabxFJLnNs7haWj7U7431gBaHvuyv7NuNDiy8dw== =1Br4
Newsgroups: comp.std.c++
Originator: austern@isolde.mti.sgi.com


Jason Merrill <jason@cygnus.com> writes:

|>  >>>>> Brian Parker <bparker@gil.com.au> writes:
|>  
|>  > Trouble is, the STL also plays aliasing games. In fact, many classes
|>  > using dynamically allocated memory would fall prey to the 12.8/5 bugs.
|>  >  I repeat here a previously posted example using STL (it involves
|>  > 12.8/5 being used to elide the copy on pass-by-value).
|>  
|>  In this testcase, the problem occurs because even though 'v' is not
|>  directly used after the call, references to data it controls are.  This
|>  would not be a problem if 'v' went out of scope immediately after the
|>  call, because any references to its data are undefined after it goes out of
|>  scope.  Thus, I suggest that 12.8/15 should be reworded to read 
|>  
|>  15Whenever an automatic (_basic.stc.auto_) class object is copied and the
|>    original object and the copy have the same type, and the block containing
|>    the original object exits (_stmt.jump_) immediately after the copy is
|>    created, an implementation is permitted to treat the original and the
|>    copy as two different ways of referring to the same object and not
|>    perform a copy at all.  In that case, the object is destroyed when the
|>    copy would have been destroyed without the optimization.
|>  
|>  I think this only allows the RVO.

It may not even allow that, if the function has local variables.  There
may be calls to other destructors between the moment the return value is
copied and the destructor of the object being copied.

-- 
James Kanze      home:     kanze@gabi-soft.fr        +33 (0)1 39 55 85 62
                 office:   kanze@vx.cit.alcatel.fr   +33 (0)1 69 63 14 54
GABI Software, Sarl., 22 rue Jacques-Lemercier, F-78000 Versailles France
            -- Conseils en informatique industrielle --
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



