From -616501153472155521
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,f5d433881cc29cff
X-Google-Attributes: gidf78e5,public
From: bparker@gil.com.au (Brian Parker)
Subject: Re: Named return value optimisation- reprise.
Date: 1997/06/24
Message-ID: <33af2b97.11315309@news.ipswich.gil.com.au>#1/1
X-Deja-AN: 252287009
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> <33a87d7b.3835586@news.ipswich.gil.com.au> <33a9da21.2670962@news.ipswich.gil.com.au> <33AACCA6.6C30@sr.hp.com>
X-Original-Date: Tue, 24 Jun 1997 03:33:46 GMT
Organization: Global Info-Links News Server
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBM7AVS0y4NqrwXLNJAQHivAH9F4tlNmfX8pEb1aMTSs1cr59K5zadE3fJ m0ZMBc98Nm7s73v3V66VcK7pKKA+GZsEMVMPtFWzpMPUE62sylh/QA== =mjLu
Newsgroups: comp.std.c++
Originator: austern@isolde.mti.sgi.com


On 23 Jun 1997 13:42:42 PDT, Mike Ferrel <mferrel@sr.hp.com> wrote:
>...
>I have been following this thread with some bemusement, and can't
>understand how a compiler could possibly replace a call-by-value with a
>call by reference. The function body would have to contain entirely 
>different code.  For this to be possible, the compiler would have to
>generate different function bodies containing code to accept value
>parameters
>as value parameters, and as reference parameters.  For functions with
>more
>than one value parameter, the exponential increase in numbers of
>distinct function bodies would cause impossible code bloat.
>
>The only way I see the compiler could possibly reasonably alter call 
>semantics is if the function were declared static, and its definition
>occured after all calls, and the compiler had determined that the
>optimisation could be used in all calls.  It seems like that's an awful
>lot of compiler housekeeping for an exceedingly rare occurence.  I can't
>imagine any implementer going to the effort.

Using an inlined function could result in the optimisation being
applied differently in different compilation units. 

The problem is that even if the optimisation was only applied rarely,
just the possibility of its application means that one must code as if
it will be applied.

,Brian Parker (bparker@gil.com.au)
---
[ 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 
]



