Graham Davies wrote:
David Brown wrote (in part):
"... since the local variable is volatile,
it has to be put on the stack."
I don't see how that follows (if it is declared automatic and is of
It would be more correct to say that since the local variable is
volatile, *gcc* puts it on the stack. As you imply, there is no strict
requirement that the variable is put in memory anywhere (nor is there
even a strict requirement that there is a stack at all). It would be
perfectly acceptable for the compiler to put such a local volatile
variable in a register.
I am in fact not entirely convinced that the compiler has to generate
anything at all here, even with the volatile - it could perhaps reason
that since there is no way for anything outside the program to find out
where the local volatile variable resides, there is no way for anything
else to influence or use the variable, and therefore the "volatile"
qualifier can be ignored.
AVR-GCC-list mailing list