[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] case statement broken in 4.1.2?
From: |
Henning Paul |
Subject: |
[avr-gcc-list] case statement broken in 4.1.2? |
Date: |
Tue, 28 Nov 2006 08:37:42 +0100 |
User-agent: |
KMail/1.9.5 |
Hi mailing list,
I have discovered a strange bug while trying to compile the firmware for the
AVR-Doper from http://www.obdev.at/products/avrusb/avrdoper.html (an USB
STK500 compatible HV and LV programmer). Using an if construction
#define SWITCH_START if(0){
#define SWITCH_CASE(value) }else if(cmd == (value)){
#define SWITCH_CASE2(v1,v2) }else if(cmd == (v1) || cmd == (v2)){
#define SWITCH_CASE3(v1,v2,v3) }else if(cmd == (v1) || cmd == (v2) || (cmd ==
v3)){
#define SWITCH_CASE4(v1,v2,v3,v4) }else if(cmd == (v1) || cmd == (v2) || cmd
== (v3) || cmd == (v4)){
#define SWITCH_DEFAULT }else{
#define SWITCH_END }
the firmware works perfectly and no warning is produced:
address@hidden:~/Download/AVR-Doper.2006-10-23/firmware> make stk500protocol.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DDEBUG_LEVEL=0 -c
stk500protocol.c -o stk500protocol.o
stk500protocol.c: In function 'stkEvaluateRxMessage':
stk500protocol.c:137: warning: pointer targets in passing argument 1
of 'strcpy_P' differ in signedness
stk500protocol.c:137: warning: pointer targets in passing argument 2
of 'strcpy_P' differ in signedness
but if I use a case construction
#define SWITCH_START switch(cmd){{
#define SWITCH_CASE(value) }break; case (value):{
#define SWITCH_CASE2(v1,v2) }break; case (v1): case(v2):{
#define SWITCH_CASE3(v1,v2,v3) }break; case (v1): case(v2): case(v3):{
#define SWITCH_CASE4(v1,v2,v3,v4) }break; case (v1): case(v2): case(v3):
case(v4):{
#define SWITCH_DEFAULT }break; default:{
#define SWITCH_END }}
the assembler throws a warning:
address@hidden:~/Download/AVR-Doper.2006-10-23/firmware> make stk500protocol.o
avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DDEBUG_LEVEL=0 -c
stk500protocol.c -o stk500protocol.o
stk500protocol.c: In function 'stkEvaluateRxMessage':
stk500protocol.c:137: warning: pointer targets in passing argument 1
of 'strcpy_P' differ in signedness
stk500protocol.c:137: warning: pointer targets in passing argument 2
of 'strcpy_P' differ in signedness
/tmp/ccDpgAHu.s: Assembler messages:
/tmp/ccDpgAHu.s:147: Warning: expression dangerous with linker stubs
/tmp/ccDpgAHu.s:148: Warning: expression dangerous with linker stubs
and the firmware isn't working. I have contacted the programmer from obdev.at
and he told me he didn't have these problems with GCC 3.4.x and considers
this a bug of GCC 4.x.
The versions of GCC and as used by me are:
address@hidden:~/Download/AVR-Doper.2006-10-23/firmware> avr-gcc -v
Using built-in specs.
Target: avr
Configured
with: ../configure --prefix=/opt/cross --with-local-prefix=/usr/local
--infodir=/opt/cross/share/info --mandir=/opt/cross/share/man
--libdir=/opt/cross/lib --libexecdir=/opt/cross/lib --enable-languages=c,c++
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.1.2
--enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib
--with-system-zlib --enable-shared --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --disable-nls --disable-shared --target=avr
--host=i586-suse-linux
Thread model: single
gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)
address@hidden:~/Download/AVR-Doper.2006-10-23/firmware> avr-as --version
GNU assembler 2.17.50.0.5 20060927 (SUSE Linux)
Copyright 2005 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
This assembler was configured for a target of `avr'.
Sources and assembler output for both cases are attached.
Thank you.
regards
Henning
stk500protocol.c
Description: Text Data
stk500protocol.s.if
Description: Text Data
stk500protocol.s.case
Description: Text Data
- [avr-gcc-list] case statement broken in 4.1.2?,
Henning Paul <=