This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/16884] New: [avr-gcc] bug while initialising variables


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.

-- 
           Summary: [avr-gcc] bug while initialising variables
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: em at la dot mine dot nu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16884


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]