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

  1. Path: sparky!uunet!UB.com!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.715445565@thor>
  6. Date: 2 Sep 92 14:52:45 GMT
  7. References: <rmartin.715101472@thor> <1992Aug31.162915.2577@Warren.MENTORG.COM> <rmartin.715356168@thor> <1992Sep1.154828.687@Warren.MENTORG.COM>
  8. Sender: news@Rational.COM
  9. Lines: 39
  10.  
  11. adk@Warren.MENTORG.COM (Ajay Kamdar) writes:
  12.  
  13. |In article <rmartin.715356168@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
  14. |>adk@Warren.MENTORG.COM (Ajay Kamdar) writes:
  15. |>
  16.  
  17. |  - example where implicit conversion of a temporary to char* is ok deleted -
  18.  
  19. |>|I wouldn't want the compiler to issue warnings in such a case, irrespective
  20. |>|of whether operator char*() was called on a temporary or not.
  21. |>
  22. |>Then, you should cajole your compiler vender into supplying you with a
  23. |>compiler which provides you with the type of #pragma control that lets
  24. |>you supress the warnings on a function by function basis.
  25.  
  26. |[...] But if it is a language standard that you are advocating, then
  27. |depending upon pragmas (which are implementation dependent by
  28. |definition) to silence warnings from code which is perfectly ok seems
  29. |inappropriate to me. If the standard specifies the generation of
  30. |warnings, it had better make sure that it enables the compilers to
  31. |generate warnings only for the problematic cases and not for good
  32. |code.
  33.  
  34. |Warning about conversion of a temporary to pointer or reference is a nice
  35. |goal to shoot for, but that needs the language to be enhanced to enable
  36. |the compilers to do a good job of it. 
  37.  
  38. Unfortunately, in the absence of a foolproof mechanisms for deletion
  39. of temporaries, the warnings are the only defence you have against the
  40. creation of long lived pointers or references to dead temporaries...
  41. Ugly as spurious warnings are, silent errors are much worse.  (IMHO).
  42.  
  43.  
  44.  
  45. --
  46. Robert Martin                        Training courses offered in:
  47. R. C. M. Consulting                       Object Oriented Analysis
  48. 2080 Cranbrook Rd.                        Object Oriented Design
  49. Green Oaks, Il 60048 (708) 918-1004       C++
  50.