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

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

Re: [avr-gcc-list] Problem with delay loop


From: Graham Davies
Subject: Re: [avr-gcc-list] Problem with delay loop
Date: Mon, 01 Oct 2007 20:55:47 -0400

Eric Weddington wrote:
... We were discussing the possibility of the
compiler being smarter about 'volatile' and
local automatic variables. I would definitely
say that if the local variable's address is taken,
then all bets are off.

Second point first. If the address of a variable is taken then the compiler cannot put it in a register. If it is declared automatic, it goes on the stack, if there is one, or somewhere else in memory if there isn't. We put the address of variables on the stack into globals at our peril, but get away with it if we know what we're doing. Nobody disagreed with any of this, but I thought it worth saying.

First point second. I think I agree with you about the possibility of the compiler being really smart and figuring out that no way could a variable be seen outside of the local scope so to hell with it. But, the standard doesn't take that approach so such a compiler would be non-standard. I disagree with the people saying that the standard isn't very clear about what volatile means. I think it's very clear. A conforming compiler will never optimize away any access to a volatile variable. Nor will it perform additional accesses, for example by using it to store intermediate values in a calculation. I think the idea that the standard isn't clear comes from non-conforming compilers.

Graham.






reply via email to

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