16884 – [3.4 Regression] [fweb related] bug while initialising variables (original) (raw)
| int main( void ) { unsigned char s[8] = { 0x6E, 0x4E, 0xF7, 0x07, 0x41, 0xFA, 0xB9, 0xD4 }; unsigned char d[8] = { 0x1B, 0x55, 0x7C, 0xE6, 0x54, 0xAC, 0x54, 0xDB }; return 0; } Compile it with avr-gcc version 3.4.0 and the following flags: CPFLAGS = -mmcu=atmega16 -g -O3 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -W The generated code looks like this: unsigned char s[8] = { 0x6E, 0x4E, 0xF7, 0x07, 0x41, 0xFA, 0xB9, 0xD4 }; 96: 88 e0 ldi r24, 0x08 ; 8 98: a0 e6 ldi r26, 0x60 ; 96 9a: b0 e0 ldi r27, 0x00 ; 0 9c: fe 01 movw r30, r28 9e: 31 96 adiw r30, 0x01 ; 1 a0: 0d 90 ld r0, X+ a2: 01 92 st Z+, r0 a4: 8a 95 dec r24 a6: e1 f7 brne .-8 ; 0xa0 unsigned char d[8] = { 0x1B, 0x55, 0x7C, 0xE6, 0x54, 0xAC, 0x54, 0xDB }; a8: a8 e6 ldi r26, 0x68 ; 104 aa: b0 e0 ldi r27, 0x00 ; 0 ac: fe 01 movw r30, r28 ae: 39 96 adiw r30, 0x09 ; 9 b0: 0d 90 ld r0, X+ b2: 01 92 st Z+, r0 b4: 8a 95 dec r24 b6: e1 f7 brne .-8 ; 0xb0 For the second initialisation there is a "ldi r24, 0x08" instruction missing from the code. Comment 1 Eric Weddington 2004-08-30 19:39:30 UTC avr-gcc 3.3.2, same flags, seems to work: ------------------------ 4:bug16884.c **** unsigned char s[8] = { 0x6E, 0x4E, 0xF7, 0x07, 0x41, 0xFA, 0xB9, 0xD4 }; 69 .LM2: 70 .LBB2: 71 0008 28E0 ldi r18,lo8(8) 72 000a DE01 movw r26,r28 73 000c 1196 adiw r26,1 74 000e E0E0 ldi r30,lo8(.LC0) 75 0010 F0E0 ldi r31,hi8(.LC0) 76 0012 0190 ld __tmp_reg__,Z+ 77 0014 0D92 st X+,__tmp_reg__ 78 0016 2A95 dec r18 79 0018 E1F7 brne .-8 5:bug16884.c **** unsigned char d[8] = { 0x1B, 0x55, 0x7C, 0xE6, 0x54, 0xAC, 0x54, 0xDB }; 81 .LM3: 82 001a 28E0 ldi r18,lo8(8) 83 001c DE01 movw r26,r28 84 001e 1996 adiw r26,9 85 0020 E0E0 ldi r30,lo8(.LC1) 86 0022 F0E0 ldi r31,hi8(.LC1) 87 0024 0190 ld __tmp_reg__,Z+ 88 0026 0D92 st X+,__tmp_reg__ 89 0028 2A95 dec r18 90 002a E1F7 brne .-8 6:bug16884.c **** return 0; ------------------------ Bug confirmed with avr-gcc 3.4.1, same flags: ------------------------ 4:bug16884.c **** unsigned char s[8] = { 0x6E, 0x4E, 0xF7, 0x07, 0x41, 0xFA, 0xB9, 0xD4 }; 69 .LM2: 70 0008 88E0 ldi r24,lo8(8) 71 000a A0E0 ldi r26,lo8(.LC0) 72 000c B0E0 ldi r27,hi8(.LC0) 73 000e FE01 movw r30,r28 74 0010 3196 adiw r30,1 75 0012 0D90 ld __tmp_reg__,X+ 76 0014 0192 st Z+,__tmp_reg__ 77 0016 8A95 dec r24 78 0018 E1F7 brne .-8 5:bug16884.c **** unsigned char d[8] = { 0x1B, 0x55, 0x7C, 0xE6, 0x54, 0xAC, 0x54, 0xDB }; 80 .LM3: 81 001a A0E0 ldi r26,lo8(.LC1) 82 001c B0E0 ldi r27,hi8(.LC1) 83 001e FE01 movw r30,r28 84 0020 3996 adiw r30,9 85 0022 0D90 ld __tmp_reg__,X+ 86 0024 0192 st Z+,__tmp_reg__ 87 0026 8A95 dec r24 88 0028 E1F7 brne .-8 ------------------------ There is no LDI instruction after the d[8] declaration that loads the register with the value that gets decremented with the following DEC instruction. I would suggest marking this bug as NEW. Also, please mark "Known to work" field with 3.3.2, and mark "Known to fail" field with 3.4.0, 3.4.1. Thanks Eric Weddington WinAVR Admin Comment 3 Drea Pinski 2004-09-22 13:35:14 UTC *** Bug 17602 has been marked as a duplicate of this bug. *** Comment 4 Giovanni Bajo 2004-09-23 00:28:40 UTC Denis, would you please backport the patch to the 3.4 branch so that we can close this PR? Thanks. Comment 6 Drea Pinski 2004-09-24 15:50:49 UTC Fixed. Comment 7 Drea Pinski 2004-10-17 16:24:26 UTC *** Bug 18039 has been marked as a duplicate of this bug. *** Comment 8 Ralf Corsepius 2004-10-17 20:07:01 UTC (In reply to comment #7) > *** Bug 18039 has been marked as a duplicate of this bug. *** I can confirm that the bug I had reported in PR 18039, does not occur anymore with today's GCC from gcc-3.4-branc (version 3.4.3 20041017 (prerelease)). | | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |