Dale Johannesen wrote:
However, as a QOI issue, I believe the compiler should treat the reference as
volatile if either the object or the lvalue is volatile. That is obviously the
user's intent.
I'm not disagreeing with you, but I wonder at gcc's ability to make good on such a promise. A cast introducing a volatile qualifier will be a NOP_EXPR, and gcc tends to strip those at every opportunity.
Also, I wonder about the following example
int const avail = <something>
int main() { while (*(int *)&avail == Foo ()) do_something(); return 0; }
Seeing through the const-stripping cast is a useful optimization. We'd have to have one rule for adding volatile and a different one for removing const.
A further pathelogical case would be,
int main() { while (*(int *)(volatile int *)&avail) do_something (); return 0; }
What should this do, treat the volatile qualifier as sticky?
nathan
-- Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC [EMAIL PROTECTED] :: http://www.planetfall.pwp.blueyonder.co.uk