On May 4, 2006, at 2:45 PM, Gary Funck wrote:
I've been looking at how GCC 4.0 handles "volatile" internally,
and may have a question/two on that later, but in the meantime,
I noticed some interesting differences in generated code that I
thought were a bit unusual, and was wondering if someone here
might explain why GCC behaves as it does

Yeah, someone brings this issue up one every 2 or 3 years. This is like the 5th round now. Check the archive (and source code) for volatile_ok and my name.

Because we're lazy is the answer you seek. :-( If you want to step forward and fix it, I'd be happy to go into more depth. It something like 20 lines to get started, and then audit the entire port to ensure nothing `funny' is done.

Is there a technical reason that the use of "volatile" would
dictate the second form of increment that first loads the
value from memory into a register?

No.

I would think that a systems programmer might expect the opposite behavior, where "volatile" would imply the single instruction form of increment (which is non-interruptible on single processor systems).

Yes.

Reply via email to