David Brown wrote:
[...]
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.
This sentence makes no sense at all. The "volatile" is precisely to warn
the compiler that it should not "reason" anything about this variable.
If you give a volatile qualifier to a local variable, it's obvious that
you want it to behave differently from regular local variables, so I
think gcc is doing the best it can, from the weakly defined volatile
semantics.
This makes as much sense as saying that any volatile is futile, since
you can compile a program with "-combine -whole-program" and so the
compiler can always "reason" that any variable will not be accessed
outside of its control.
Note that I'm not disputing that the compiler could in theory use a
register instead. I personally don't think that would be a good idea,
but it might be allowed by the specs. What I'm disputing is that the
compiler _can not_ ignore the volatile and optimize the loop away
entirely. That would be a compiler bug, for sure.
--
Paulo Marques
Software Development Department - Grupo PIE, S.A.
Phone: +351 252 290600, Fax: +351 252 290601
Web: www.grupopie.com
"As far as we know, our computer has never had an undetected error."
Weisert
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list