Topic: handling of return values


Author: mark@premenos.premenos.COM (Mark Grand)
Date: 13 Apr 91 19:47:03 GMT
Raw View
My understanding of the semantic of the return statement is that the
expression following return is evalated, a copy of the value is
created using the appropriate copy constructor and the copy is
returned.  My question involves the circumstance

        extern MyObj foo();
                ...
        foo();

What becomes of the return value?  Borland C++ waits until it reaches
the end of the scope enclosing the call to foo() before calling the
destructor for its return value.  If a destructor is to be called then
when.  In a case such as

        extern MyObj foo();
                ...
      loop:
        foo();
                ...
        goto loop;

will a destructor be called for every value returned by foo()?
--
========

Mark Grand
Premenos Corporation                415-602-2073
1000 Burnett Avenue, Suite 200
Concord, CA   94520                 ...!attmail!premenos
        ...!{sun, ames, att}!pacbell!premenos!mark
--
========

Mark Grand
Premenos Corporation                415-602-2073