home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!hal.com!decwrl!sdd.hp.com!cs.utexas.edu!devnull!rgp
- From: rgp@mpd.tandem.com (Ramon Pantin)
- Newsgroups: comp.lang.c++
- Subject: Re: destruction of temporaries
- Message-ID: <2285@devnull.mpd.tandem.com>
- Date: 21 Aug 92 02:54:45 GMT
- References: <1992Aug17.073500.24115@ericsson.se> <TMB.92Aug20142610@arolla.idiap.ch> <1992Aug20.190313.3407@lucid.com>
- Sender: news@devnull.mpd.tandem.com
- Organization: Tandem Computers, Micro-Products Division
- Lines: 43
-
- In article <1992Aug20.190313.3407@lucid.com> jss@lucid.com (Jerry Schwarz) writes:
- >In article <TMB.92Aug20142610@arolla.idiap.ch>, tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
- >
- >|> Let me put in another vote for leaving things the way they are.
- >|
- >
- >There may be some confusion about where we are now. The ARM (and the
- >x3j16 working paper) give compilers a lot of freedom about where
- >to destroy temporaries.
- >
- >This is generally considered unsatisfactory because it means
- >that programs frequently break when move between compilers with
- >different strategies. If all compilers were making the same
- >or similar choices in this area x3j16 could just standardize that
- >decision. The reason this didn't happen is that there are good arguments
- >for a variety of different strategies.
-
- I've got a simple (poor man's?) solution to this problem:
-
- Let the compiler destroy temporaries as soon as it wishes
- to do so, with the exception of objects for which a member function
- that has been declared with a new keyword (say "longlived")
- _might_ have been executed, in which case the object persist
- until the end of the function (or some other convenient
- place for destruction).
-
- Member functions that return pointers or references to their
- internal data structures would be declared as "longlived".
- The "_might_ have been executed" above would allow enough
- freedom to the compiler implementation to make choices such as:
-
- - Add some logic to the compiler to determine if
- any of the "longlived" methods are invoked (maybe
- even some flow control analysis could be done).
-
- - Always destruct objects that have any member function
- that is "longlived" at the end of the function even
- if none of them are invoked in the body of the function.
- (Maybe classes themselves could be declared as "longlived")
-
- What do you think?
-
- Ramon Pantin
-