home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13010 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  1.3 KB

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