avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Question about gcc preprocessing and port/pin assignm


From: Graham Davies
Subject: Re: [avr-gcc-list] Question about gcc preprocessing and port/pin assignments
Date: Thu, 9 Dec 2004 10:10:07 -0500

I'm a bit nervous that I've dragged this thread too far off topic and I'm on
the verge of changing the subject line but I've not figured out the list
practices in that regard.  Anyway, people do seem to be interested so this
is where I think we are.

x = exp; // when exp is some simple expression, possibly including the value
of x
Question - is the compiler permitted to implement this with multiple stores
to x if x is declared volatile?

I note that we must distinguish:
A - What we would like to happen.
B - What the language definition says must happen.
C - What actually happens in any given implementation.

Dave has provided us with a link to an unknown version of the language
specification for C99.  I hope I am not in breach of some copyright by
downloading and reading this.

>From section 5.1.2.3, page 25 of the PDF: "In the abstract machine, all
expressions are evaluated as specified by the semantics."

>From section 6.7.3, page 120 of the PDF: "... any expression referring to
[an object that has volatile-qualified type] shall be evaluated strictly
according to the rules of the abstract machine, as described in 5.1.2.3."

Taken together and reinforced by other text, these statements suggest to me
that the compiler is not permitted to introduce optimizations or other
changes that would result in multiple stores to a volatile-qualified lvalue.
I admit that this is not wonderfully clear and talk of sequence points
muddies the water considerably.  Note that the sequence point stuff is a
"furthermore" and so is in addition to the above and not a clarification of
it.  The semantics I'm relying on here, by the way, are operator precedence
rules which put the assignment operator pretty much at the bottom.  I do
understand that there is also this thing called order of evaluation but I
can't see how it makes the semantics any the less certain in this case.

Graham.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]