This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/27556] Wrong code generation when cross compile for attiny2313
- From: "p dot mateja at sh dot cvut dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 May 2006 21:42:48 -0000
- Subject: [Bug target/27556] Wrong code generation when cross compile for attiny2313
- References: <bug-27556-12672@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from p dot mateja at sh dot cvut dot cz 2006-05-11 21:42 -------
(In reply to comment #1)
> That's not a complete testcase, which we need to reproduce/fix the bug.
What do you need?
Complete source is:
cat >test.c <<EOF
#include <avr/io.h>
int main(void)
{
UBRRH = 0;
UBRRL = 4;
UCSRB = (1<<RXEN) | (1<<TXEN);
UCSRC = (1<<UCSZ0) | (1<<UCSZ1);
char text[] =
"01234567890123456789"
"01234567890123456789"
"01234567890123456789"
"01234567890123456789"
"01234567890123456789"
"01234567890123456789"
"0123456";
char *pointer = text;
while (*pointer) {
UDR = *pointer;
while ( !(UCSRA & (1<<UDRE)));
pointer++;
}
return 0;
}
EOF
Just run
avr-gcc -mmcu=attiny2313 -Wall -Os -c test.c
And you will get the long string on ATtiny's UART after uploading the program
into avr's flash.
If you change the last line in array definition to
"01234567";
CPU will be be lost in endless loop and you will get no output on UART at all.
I was trying to find the bug in my sources, but the gcc definitely generates
code which supposes that the array is smaller than 128 bytes using just 8-bit
register for the loop.
Part of output of avr-gccbug:
System: Linux lemra 2.6.17-rc2 #3 PREEMPT Fri Apr 21 15:28:09 CEST 2006 i686
GNU/Linux
Architecture: i686
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: avr-unknown-none
configured with: ../build-tree/gcc-4.1.0/configure -v --enable-languages=c,c++
--prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --enable-shared
--with-system-zlib --enable-long-long --enable-nls --without-included-gettext
--disable-checking --disable-libssp --build=i486-linux-gnu
--host=i486-linux-gnu --target=avr
--
p dot mateja at sh dot cvut dot cz changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |p dot mateja at sh dot cvut
| |dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27556