From: Strobl A. <a.s...@aw...> - 2010-08-01 11:02:57
|
Dear Raphael, dear SDCC developers, attached you can find a minimal project to reproduce the bug. If struct value ".d1" is set to zero and afterwards ".d0" is set to zero ".d0" will be interpreted as long instead as unsigned char? Tested with r5530 and r5896 - same problem. Regards, Strobl Anton main.c: ============================================================== typedef union { struct { unsigned char d0; unsigned char d1; unsigned char d2; unsigned char d3; unsigned char d4; unsigned char d5; unsigned char d6; unsigned char d7; }; struct { unsigned char bytes[8]; }; } MYSTATE; MYSTATE test1; MYSTATE test2; volatile MYSTATE test3; volatile MYSTATE test4; void main(void) { test1.d1=0; // ok test1.d0=0; /* generated assembler code false clears also test1.d1, test1.d2 and test1.d3 */ test2.d0=0; // ok test2.d1=0; // ok // test with volatile declared vars test3.d1=0; // if defined as volatile - ok test3.d0=0; // ok test4.d0=0; // ok test4.d1=0; // ok } main.asm (partially) ============================================================== _main ;Function start ; 2 exit points ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 ; .line 25; "main.c" test1.d1=0; // ok BANKSEL _test1 CLRF (_test1 + 1) ;gen.c:5941: size=3/8, offset=0, AOP_TYPE(res)=8 ; .line 26; "main.c" test1.d0=0; // generated assembler code false clears also test1.d1, test1.d2 and test1.d3 CLRF (_test1 + 0) ;gen.c:5941: size=2/8, offset=1, AOP_TYPE(res)=8 CLRF (_test1 + 1) ;gen.c:5941: size=1/8, offset=2, AOP_TYPE(res)=8 CLRF (_test1 + 2) ;gen.c:5941: size=0/8, offset=3, AOP_TYPE(res)=8 CLRF (_test1 + 3) ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 ; .line 28; "main.c" test2.d0=0; // ok BANKSEL _test2 CLRF (_test2 + 0) ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 ; .line 29; "main.c" test2.d1=0; // ok CLRF (_test2 + 1) ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 ; .line 32; "main.c" test3.d1=0; // if defined as volatile - ok BANKSEL _test3 CLRF (_test3 + 1) ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 ; .line 33; "main.c" test3.d0=0; // ok CLRF (_test3 + 0) ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 ; .line 35; "main.c" test4.d0=0; // ok BANKSEL _test4 CLRF (_test4 + 0) ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 ; .line 36; "main.c" test4.d1=0; // ok CLRF (_test4 + 1) RETURN ; exit point of _main |
From: Maarten B. <sou...@ds...> - 2010-08-01 19:59:35
|
Hello Anton, Please don't send bug reports to the mailing list. They run a high risk of being forgotten. It should be filed in the bugtracker at sourceforge. Thank you, Maarten > Dear Raphael, dear SDCC developers, > > attached you can find a minimal project to reproduce the bug. > > If struct value ".d1" is set to zero > and afterwards ".d0" is set to zero > ".d0" will be interpreted as long instead as unsigned char? > > Tested with r5530 and r5896 - same problem. > > Regards, Strobl Anton > > > > main.c: > ============================================================== > typedef union { > struct { > unsigned char d0; > unsigned char d1; > unsigned char d2; > unsigned char d3; > unsigned char d4; > unsigned char d5; > unsigned char d6; > unsigned char d7; > }; > struct { > unsigned char bytes[8]; > }; > } MYSTATE; > > MYSTATE test1; > MYSTATE test2; > > volatile MYSTATE test3; > volatile MYSTATE test4; > > void main(void) > { > test1.d1=0; // ok > test1.d0=0; /* generated assembler code false clears > also test1.d1, test1.d2 and test1.d3 */ > > test2.d0=0; // ok > test2.d1=0; // ok > > // test with volatile declared vars > test3.d1=0; // if defined as volatile - ok > test3.d0=0; // ok > > test4.d0=0; // ok > test4.d1=0; // ok > } > > > > main.asm (partially) > ============================================================== > _main ;Function start > ; 2 exit points > ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 > ; .line 25; "main.c" test1.d1=0; // ok > BANKSEL _test1 > CLRF (_test1 + 1) > ;gen.c:5941: size=3/8, offset=0, AOP_TYPE(res)=8 > ; .line 26; "main.c" test1.d0=0; // generated assembler code false > clears also test1.d1, test1.d2 and test1.d3 > CLRF (_test1 + 0) > ;gen.c:5941: size=2/8, offset=1, AOP_TYPE(res)=8 > CLRF (_test1 + 1) > ;gen.c:5941: size=1/8, offset=2, AOP_TYPE(res)=8 > CLRF (_test1 + 2) > ;gen.c:5941: size=0/8, offset=3, AOP_TYPE(res)=8 > CLRF (_test1 + 3) > ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 > ; .line 28; "main.c" test2.d0=0; // ok > BANKSEL _test2 > CLRF (_test2 + 0) > ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 > ; .line 29; "main.c" test2.d1=0; // ok > CLRF (_test2 + 1) > ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 > ; .line 32; "main.c" test3.d1=0; // if defined as volatile - ok > BANKSEL _test3 > CLRF (_test3 + 1) > ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 > ; .line 33; "main.c" test3.d0=0; // ok > CLRF (_test3 + 0) > ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 > ; .line 35; "main.c" test4.d0=0; // ok > BANKSEL _test4 > CLRF (_test4 + 0) > ;gen.c:5941: size=0/1, offset=0, AOP_TYPE(res)=8 > ; .line 36; "main.c" test4.d1=0; // ok > CLRF (_test4 + 1) > RETURN > ; exit point of _main > > > |