Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: SourceForge.net <noreply@so...> - 2007-11-25 09:38:37
|
Bugs item #1838000, was opened at 2007-11-25 01:32 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1838000&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: msc51(8051) target Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Bad code for a bitfield in triple operator Initial Comment: SDCC 2.7.0 produces erroneous code for a statement like *bp++ = sp->b ? 'A' : 'B'; The compiled code will crash when executed. More details in the enclosed file. Submitted by: j (dot) kangas (at) luukku (dot) com ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2007-11-25 01:38 Message: Logged In: NO System sis not accept the enclosed file, I'll enclose it here: /* Demonstrates a problem in SDCC 2.7.0 This program will crash when run in an 8051. The error is on the line marked below. The compiler produces PUSH AR0, but the corresponding POP AR0 is misplaced and is not executed when s.b is 0. This leaves stack corrupted and executing RET in the end of func() crashes the program. The assembly for the marked statement: ; triple.c:33: *bp++ = sp->b ? 'A' : 'B'; mov ar1,r0 inc r0 push ar0 mov r0,#_s movx a,@r0 jnb acc.0,00103$ pop ar0 mov r2,#0x41 sjmp 00104$ 00103$: mov r2,#0x42 00104$: mov @r1,ar2 Compiler command line: sdcc --xram-size 256 triple.c Compiler version: SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.7.0 #4818 (May 31 2007) (MINGW32) Submitted by: j dot kangas at luukku dot com */ typedef struct st { unsigned char b:1; } ST; __pdata ST s; __idata unsigned char buf[5]; void func( void ) { __pdata ST *sp; __idata unsigned char *bp; sp = &s; bp = buf; *bp++ = sp->b ? 'A' : 'B'; // statement producing bad code *bp++ = 'C'; } void main( void ) { s.b = 0; func(); while (1); } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1838000&group_id=599 |