gcc optimization return value handling

rekisum@web.de rekisum@web.de
Fri Jan 16 16:09:00 GMT 2009


Originally I had:

if( menu_descend() )
or 
if( menu_descend() != 0 )

I added ret as I found that the problem lies here.
Or, that is what I think. Maybe the is some other error around.
The stack seems to be ok btw.
The problem is not the wrong interpretation of the return value
but there gets something corrupted when not using volatile.
Don't understand the setjmp thing, but also don't see this in the assembler.
I'll try to change the optimisation from 2 to s.
The program should fit in FLASH and I may get more hints.

 
> >       ret = menu_descend(); 
> >       if( ret != 0 ) 
> >       { . . . . . 
> > .
   
> My guess is that you have an uninitialized variable somewhere [else], 
> and by making ret
> a volatile, you just happen to see the desired results.
> 
> With what you've shown, r3 is now going to be 0 after your call, so is 
> the word at sp+84.
> And perhaps, you'll see a different amount of stack space allocated in 
> this function -
> all have the possibility of changing the "undefined" value of an 
> uninitialized variable.
> 
> 
> 


____________________________________________________________________
Psssst! Schon vom neuen WEB.DE MultiMessenger gehört? 
Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123



More information about the Gcc-help mailing list