declaration of static function corrupts main function

Bug #620646 reported by Tom Fields
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-avr (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: gcc-avr

Hi,

gcc-Version 4.3.5 (GCC), AMD64 default Maverick package.

The attached source file (see also the preprocessed input) yields corrupted machine code:

The short example "control_unit.c" contains a single for(i=0; i<6; i++)-loop that is supposed to run exactly six times.
Instead, the compiler produces a loop with undetermined behaviour that runs tens of times at least.

I compiled with the following command line for target ATTiny26:
avr-gcc -v -save-temps -c -std=c99 -g -Os -Wall -Wstrict-prototypes -Wextra -Wa,-ahlms=control_unit.lst -mmcu=attiny26 control_unit.c

I've also attached the messages displayed during the above compile run in the file "stdout-compile-messages.txt"

That file also contains the GCC options with which GCC for the AVR target was configured.

Regards,
Ulrich

Revision history for this message
Tom Fields (udzelem) wrote :
Revision history for this message
Tom Fields (udzelem) wrote :
Revision history for this message
Tom Fields (udzelem) wrote :
Revision history for this message
Tom Fields (udzelem) wrote :

Amendment 1: If the source file is modified as in this attachement, the error is gone, and the compiled result works as expected.

What was changed: the function "owioReceiveWord()" is /not/ declared static in this case.

Attachement: control_unit.WORKS.c

Revision history for this message
Tom Fields (udzelem) wrote :
Revision history for this message
Tom Fields (udzelem) wrote :

Current /official/ GCC release version 4.5.1 does NOT produce the erroneous result.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.