home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19952 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.4 KB  |  38 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!uunet.ca!frumious!pat
  3. From: pat@frumious.uucp (Patrick Smith)
  4. Subject: Re: Overloading Operators
  5. Message-ID: <C1H383.1Jy@frumious.uucp>
  6. Date: Tue, 26 Jan 1993 17:57:38 GMT
  7. Reply-To: uunet.ca!frumious!pat
  8. References: <C13BK9.Lr@frumious.uucp> <2215@celia.UUCP> <9302623.13017@mulga.cs.mu.OZ.AU>
  9. Organization: None
  10. Lines: 26
  11.  
  12. Some time ago, I wrote:
  13. |>> Like Nikki, I can't think of any way in which a const or volatile
  14. |>> reference differs from a plain reference.  Is there a difference?
  15.  
  16. Actually, if I remember correctly, Nikki only mentioned const
  17. references.  The blindness about volatile references was mine alone.
  18.  
  19.  
  20. fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  21. |I agree with the earlier statements that const references don't differ from
  22. |plain references. But I can see that a volatile reference might differ from
  23. |a plain reference, although I see no useful way of using this difference.
  24. |
  25. |    int i;
  26. |    int & volatile ref = i;        // 'volatile' here prevents compiler
  27. |                    // from optimizing away 'ref' if
  28. |                    // it is not used?
  29.  
  30. Yes, of course.  Also, uses of volatile references can't be
  31. optimized away (and multiple uses can't be optimized into a
  32. single pointer fetch from memory).  Silly of me to miss this.
  33.  
  34. -- 
  35. Patrick Smith
  36. uunet.ca!frumious!pat
  37. pat%frumious.uucp@uunet.ca
  38.