From: SourceForge.net <no...@so...> - 2003-09-27 07:10:00
|
Bugs item #813206, was opened at 2003-09-26 13:03 Message generated for change (Comment added) made by epetrich You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=813206&group_id=599 Category: Icode generator >Group: fixed >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Stas Sergeev (stsp) >Assigned to: Erik Petrich (epetrich) Summary: The "default" case is not being handled Initial Comment: Hi. I was trying to compile a small test program with sdcc, and it fails on a very simple "switch" because sdcc doesn't handle the "default" case. The program is attached. Also here it is: --- #include <at89S8252.h> int main() { char a, b; b = SBUF; switch (b) { case 1: a = 'a'; break; case 2: a = 'b'; break; default: a = 'c'; } return a; } --- The command line is: sdcc -mmcs51 --nojtbound --noinduction --noloopreverse --xram-size 0 --code-size 8192 --debug --no-peep switch.c The generated (bad) asm follows: --- ;switch.c:7: switch (b) { ; genMinus ; genMinusDec dec r2 ; genJumpTab mov a,r2 add a,acc add a,r2 mov dptr,#00107$ jmp @a+dptr 00107$: ljmp 00101$ ljmp 00102$ C$switch.c$8$2$2 ==. ;switch.c:8: case 1: a = 'a'; 00101$: ; genAssign mov r2,#0x61 C$switch.c$9$2$2 ==. ;switch.c:9: break; ljmp 00104$ C$switch.c$10$2$2 ==. ;switch.c:10: case 2: a = 'b'; 00102$: ; genAssign mov r2,#0x62 C$switch.c$13$1$1 ==. ;switch.c:13: } 00104$: C$switch.c$14$1$1 ==. ;switch.c:14: return a; --- There is no code for the "default" case. As "b" contains some garbage, the code just jumps to an undefined location with the dire consequinces. This bug seems to be very severe. Our programs behaves very strangely and unreliably due to it. sdcc is from CVS. ---------------------------------------------------------------------- >Comment By: Erik Petrich (epetrich) Date: 2003-09-27 02:09 Message: Logged In: YES user_id=635249 Fixed in src/SDCCicode 1.167 (--nojtbound option is now ignored for switches with a default case) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=813206&group_id=599 |