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