> Date: Fri, 28 Sep 2007 14:21:38 +0530> To: [EMAIL PROTECTED]> Subject: Re: 
> [avr-gcc-list] Problem with delay loop> From: [EMAIL PROTECTED]> CC: 
> AVR-GCC-list@nongnu.org> > Hi,> > On Fri, 28 Sep 2007 13:42:18 +0530, Klaus 
> Rudolph <[EMAIL PROTECTED]> wrote:> > > The code has been optimized. Well 
> done!> > If you need the variable access use 'volatile'> >> Why does it get 
> optimised?
Because it is allowed, and gcc is sophisticated enough to do so.
> I understand the meaning of 'volatile', but why is it required here ?
What is the meaning of volatile?  Hint: it has nothing to do with "sharing."
> It is clear that the variable is changing in the code itself (not outside it).
Precisely.  The optimizer recognized that neither the intermediate values nor 
even the final value of the variable had any effect on the outcome of the 
program, and therefore removed the calculation of those values from the code.
> > Again- it worked in the older avr-gcc. Was that a bug(the fact that it 
> > worked)?
No.  It was a missed opportunity for optimization.  The program produced the 
same result, it just took longer to do so.
Again, you would do well to investigate the library's delay.h header and the 
facilities it provides.  These work very well.
Explore the seven wonders of the world
AVR-GCC-list mailing list

Reply via email to