Re: [avr-gcc-list] Incorrect code by gcc?

You are trying to use c as an assembler. Dont do that.
You should be able to ignore frame pointer and register details.

If you have assembler that must have certain values in registers then
use asm keyword to create assembler with parameters set to transfer c
variable to right registers. Or perhaps write function in assembler as
naked function.

But you must follow rules to avoid corruption of gcc. For example, that
means you will have to save certain registers
such as R28,R29 and R0-R17 - if you use them. Parameters are passed
and returned to function in certain registers - so you have to follow
that.

-fomit-frame-pointer will work if gcc can really omit it.
Frame pointer will be used to store "local" variables that are to big
to fit in registers and/or need to be saved around calls. It may also
use R2-R17 to save values. Many factors determine which it will use,

such as loops - speed -size - overhead of saving registers etc. It

is

not always perfect.

If you find situation where it could omit frame pointer - but does

not,

that might be a bug (gcc is not perfect - I know several parts that
could be better).

In this case (and many others i have seen) there were plenty of
registers
free to save the variable. I leave it up to you if you call it a bug
when i ask
the compiler to omit frame pointers and he still uses one. I think he
could
at least warn if he is unable. In the strict sense it is not a bug
since the

documentation states: "Don't keep the frame pointer in a register for

functions that don't need one" Given that gcc is not infinitely smart
he

might come to the conclusion he needs one. Gcc could also just use push/

pop to temporarily store the variable, but i don't know if that is
always

possible.

By all means post "bug" here first if you are not sure.

That was the intention. Next time i wait a little longer to see more
reactions ;-)

I know gcc bugs should have pre-processed sources (.i files) - but as

first

look it is easier to just look at c code. I think Eric and others

would have

spotted it sooner.

I agree

I would could still use some advise how to resolve the matter.
Sometimes

I need to make a function naked to ensure for example all registers are

left in tact when jumping to the context switch, cause normally gcc
moves
the registers used for parameters first (prolog) to other registers
before

making the call.

So how do i force gcc to use a free register or push/pop directly
instead