From: SourceForge.net <no...@so...> - 2004-02-09 17:58:45
|
Bugs item #892400, was opened at 2004-02-07 16:49 Message generated for change (Comment added) made by stsp You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=892400&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: Assign to bit var doesnt always work Initial Comment: Hi. There is a bug which makes assigning to a bit var to generate a wrong code sometimes. Here is an example: --- volatile bit a; idata unsigned char b; struct { unsigned char c; } tst; char main() { a = b; a = tst.c; return a; } --- Generated asm looks like this: --- ;bit.c:9: a = b; ; genAssign mov r0,#_b mov a,@r0 add a,#0xff mov _a,c [that's correct] ;bit.c:10: a = tst.c; ; genPointerGet ; genNearPointerGet mov r0,#_tst ; genUnpackBits mov a,@r0 anl a,#0x01 <--- BUG! add a,#0xff mov _a,c --- Test-case is attached. ---------------------------------------------------------------------- >Comment By: Stas Sergeev (stsp) Date: 2004-02-09 20:58 Message: Logged In: YES user_id=501371 Hi Erik. I have tested your fix. Yes, it produces the correct code now, yet very very suspicious. I cant help feeling there is a bug or two still here. Here is an example that keeps me worried: --- struct { unsigned char a; unsigned char b; } tst1; struct { unsigned char c; } tst2; bit b1, b2, b3; char main() { b1 = tst1.b; b2 = tst1.b; b3 = tst2.c; return 0; } --- The generated asm looks like this: --- ;struct.c:12: b1 = tst1.b; ; genAssign ; genAssign mov a,0x0001 + _tst1 add a,#0xff mov _b1,c [ perfectly correct ] ;struct.c:13: b2 = tst1.b; ; genAssign mov a,0x0001 + _tst1 add a,#0xff mov _b2,c [ perfectly correct ] ;struct.c:14: b3 = tst2.c; ; genPointerGet ; genNearPointerGet mov r0,#_tst2 mov a,@r0 add a,#0xff mov _b3,c [ why is that??? ] --- So yes, the code is correct... But what's the idea there behind the indirection in the third fragment? Almost certainly a bug... (OKey, now I am calling a perfectly valid code a bug, what's next? :) Test case is attached. As a side-note: if you change "tst2" to "tst1" in that example, so that the symbol is duplicated, the error message is not perfect: --- struct.c:7: error: Duplicate symbol 'tst1', symbol IGNORED from type 'struct __00010000' to type 'struct __00010001' --- Something cryptical here definitely. ---------------------------------------------------------------------- Comment By: Stas Sergeev (stsp) Date: 2004-02-08 17:36 Message: Logged In: YES user_id=501371 Thanks, good to see it fixed. This bug "bugged" me exactly when I was demonstrating my program to the boss. Fortunately, got used to the fact that the bugs are to be looked up in a generated asm rather than in a source code, I was able to identify and work around the problem before his patience run out:) ---------------------------------------------------------------------- Comment By: Erik Petrich (epetrich) Date: 2004-02-08 12:00 Message: Logged In: YES user_id=635249 Fixed in all of the code generators that have a type "bit" separate from bitfields: src/mcs51/gen.c 1.192, src/ds390/gen.c 1.214, src/pic/gen.c 1.89, src/pic16/gen.c 1.19 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=892400&group_id=599 |