This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for EH-only cleanups, part 1 (for c++/5636)


>>>>> "Richard" == Richard Henderson <rth@redhat.com> writes:

> On Thu, Apr 04, 2002 at 12:52:15AM +0100, Jason Merrill wrote:
>> My named return value code was a bit over-enthusiastic about nullifying
>> cleanups for a chosen local variable; if the function exits with an
>> exception, we can't expect the caller to handle destroying the variable.

> Why not?  How is this different from

>   {
>     string tmp;
>     foo (&tmp);
>   }

In this case, the string is constructed before entry to the function, so
the caller is responsible for destroying it.  In the NRV case:

  string tmp = foo ();
  ...
  string foo ()
  {
    ...
    string ret;
    ...               // here
    return ret;
  }

the string isn't constructed until "here", so the caller should not try to
take responsibility for destroying it until the function returns; in other
words, until tmp is fully initialized.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]