Re: strange grammar about volatile and operator overload



Thanks Igor,


My question is answered.


regards,
George

"Igor Tandetnik" wrote:

"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BB2B4E82-3B35-482F-A41B-5E7C60DBDC00@xxxxxxxxxxxxx
But I am not sure whether volatile is consistent to the reference
binded object. For example, the operator conversion function returns
reference to some global object and it is marked as volatile now, but
actually in the definition/declaration of the global object, it is
not marked as volatile.

That's perfectly OK. Just as you can have a reference-to-const bound to
an object that wasn't declared const:

int x;
const int& cr = x; // OK
volatile int& vr = x; // also OK

When x is accessed directly, it's not treated as volatile or const. When
x is accessed via vr reference, it's treated as volatile (meaning
certain compiler optimizations are suppressed). When x is accessed via
cr reference, it's treated as const (meaning you can read the value but
can't change it).

I am not sure about whether I have made
myself understood about the volatile consistent issue.

No, not really.

Any comments? Is it an issue

Is what an issue?

or just make the global variable in my
sample more restrictive (volatile is more restrictive than
non-volatile)?

Yes, volatile is more restrictive.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



.



Relevant Pages

  • Re: Use Lock
    ... function via a reference to a volatile object unless the function is also ... const when you have a reference to a const object. ... Combining this with the above, maybe using 'friend' to fine-tune access, ...
    (comp.programming.threads)
  • Re: strange grammar about volatile and operator overload
    ... it's not the return value itself that's volatile. ... return value is a reference, and what it refers to is what's volatile. ... definition/declaration of the global object, it is not marked as volatile. ...
    (microsoft.public.vc.language)
  • Re: strange grammar about volatile and operator overload
    ... actually in the definition/declaration of the global object, ... not marked as volatile. ... it's not treated as volatile or const. ... x is accessed via vr reference, ...
    (microsoft.public.vc.language)
  • Re: JavaScript knowledge test
    ... The assignment can produces a runtime error when the object being assigned to is a host object and it throws an exception when the assignment is made to an 'x' proeperty. ... on IE if no global 'x' variable is declared but an element exists in the DOM with the ID attribute "x" then IE creates an 'x' proeprty of the global object and assigns it a reference to the DOM element. ... The assigning of the returned inner function form that example to an intrinsic event property of a DOM node does result in the DOM node having an indirect reference to a JS object, but so long as the JS object does not then hold a reference to the DOM node the circle is not closed and no garbage collection issues follow. ...
    (comp.lang.javascript)
  • Re: this confusion
    ... by Mike Winter: ... assignment being attained through the function.prototype.call/apply ... calls in accordance with the way in which the reference to the method ... "this" is assigned a reference to the global object. ...
    (comp.lang.javascript)