Re: avr-gcc optimization issue

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

 



On 07/03/14 15:39, Henrik Juul Pedersen wrote:
> Hi, I'm not sure if this is the correct forum, but I'm not sure
> whether this is a bug, or a feature.

gcc-help can be appropriate, but if your question is very specific to
the avr port then avr-gcc-list@xxxxxxxxxx might be better.

> 
> Im working on a program for an AVR microcontroller using avr-gcc for
> the compilation.
> 
> 
> I have gotten an issue with a single function variable not being
> checked after optimization.

Do you mean a variable local to the function (as distinct from a
function pointer variable)?

> My question is: shouldn't I be able to assume that function variables
> are treated as being volatile, unless optimized away completely?

No, you should assume the compiler will do all sorts of wonderful
optimisations with local variables.  It is usually a bit more limited
with local static variables, but "normal" local variables (what used to
be called "auto" variables before C++11 usurped that keyword) can be
heavily optimised.

> Marking the function variable volatile solves the issue.
> 
> The code is compiled with -O2 -ffreestanding -Wall -Wextra and
> produces no warnings.
> 
> I have not been able to create a simple test-case, but I can supply
> the entire source upon request.
> 

It is usually not useful to have a large source file - a small test case
is best.  It is quite common that in the process of finding a small test
case that shows the problem, people find the issue themselves.

mvh.,

David






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux