home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!igor!thor!rmartin
- From: rmartin@thor.Rational.COM (Bob Martin)
- Newsgroups: comp.lang.c++
- Subject: Re: Destruction of temporaries
- Message-ID: <rmartin.715004480@thor>
- Date: 28 Aug 92 12:21:20 GMT
- References: <MCGRANT.92Aug26232410@rascals.stanford.edu> <23563@alice.att.com>
- Sender: news@Rational.COM
- Lines: 27
-
- ark@alice.att.com (Andrew Koenig) writes:
-
- |The real problems come about when, say, a String
- |class has operator const char() that returns a pointer to the internal
- |representation of the String. That then raises the problem:
-
- | String s, t;
-
- | // ...
-
- | const char* p = s + t;
-
- |and now, the question is when the temporary representing `s + t' is
- |destroyed. The point is that destroying that temporary invalidates p,
- |so it suddenly becomes an issue of great concern.
-
- It is in these cases where I would be perfectly happy if the compiler
- issued a warning, or even an error. I don't think, in the absence of
- GC, that the compiler should be responsible for tracking the
- disposition of such pointers.
-
-
- --
- Robert Martin Training courses offered in:
- R. C. M. Consulting Object Oriented Analysis
- 2080 Cranbrook Rd. Object Oriented Design
- Green Oaks, Il 60048 (708) 918-1004 C++
-