Bug 38954

Summary: AVR-GCC: internal compiler error: in start_function, at c-decl.c:6248
Product: gcc Reporter: Charles Lindsay <charles>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: charles, eric.weddington, gcc-bugs, marek.jawurek
Priority: P3    
Version: 4.3.2   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Charles Lindsay 2009-01-24 01:58:15 UTC
I was instructed by avr-gcc 4.3.2 to send a bug report.  Here's the command line:

$ avr-gcc -v -save-temps -Os -g -Wall -I. -I../usbtiny -mmcu=attiny2313 -c -o main.o main.c
Using built-in specs.
Target: avr
Configured with: ../configure --disable-libssp --disable-nls --enable-languages=c,c++ --mandir=/usr/share/man --prefix=/usr --target=avr --with-gnu-as --with-gnu-ld --with-as=/usr/bin/avr-as --with-ld=/usr/bin/avr-ld : (reconfigured) ../configure --disable-libssp --disable-nls --enable-languages=c,c++ --infodir=/usr/share/info --libexecdir=/usr/lib --mandir=/usr/share/man --prefix=/usr --target=avr --with-gnu-as --with-gnu-ld --with-as=/usr/bin/avr-as --with-ld=/usr/bin/avr-ld
Thread model: single
gcc version 4.3.2 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Os' '-g' '-Wall' '-I.' '-I../usbtiny' '-mmcu=attiny2313' '-c' '-o' 'main.o'
 /usr/lib/gcc/avr/4.3.2/cc1 -E -quiet -v -I. -I../usbtiny -imultilib avr25 main.c -mmcu=attiny2313 -Wall -fworking-directory -Os -fpch-preprocess -o main.i
ignoring nonexistent directory "/usr/lib/gcc/avr/4.3.2/../../../../avr/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 .
 ../usbtiny
 /usr/lib/gcc/avr/4.3.2/include
 /usr/lib/gcc/avr/4.3.2/include-fixed
 /usr/lib/gcc/avr/4.3.2/../../../../avr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Os' '-g' '-Wall' '-I.' '-I../usbtiny' '-mmcu=attiny2313' '-c' '-o' 'main.o'
 /usr/lib/gcc/avr/4.3.2/cc1 -fpreprocessed main.i -quiet -dumpbase main.c -mmcu=attiny2313 -auxbase-strip main.o -g -Os -Wall -version -o main.s
GNU C (GCC) version 4.3.2 (avr)
	compiled by GNU C version 4.3.2, GMP version 4.2.4, MPFR version 2.3.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 2d5f5dc20dcc192172a3e9de347166ce
main.c:168: internal compiler error: in start_function, at c-decl.c:6248
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


And here's the main.i it generates (the source is GPLed):

# 1 "main.c"
# 1 "/home/toxite/usbtiny-1.4/ir//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "main.c"
# 102 "main.c"
# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 1 3
# 99 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 3
# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/sfr_defs.h" 1 3
# 126 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/sfr_defs.h" 3
# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/inttypes.h" 1 3
# 37 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/inttypes.h" 3
# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/stdint.h" 1 3
# 121 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/stdint.h" 3
typedef int int8_t __attribute__((__mode__(__QI__)));
typedef unsigned int uint8_t __attribute__((__mode__(__QI__)));
typedef int int16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int uint16_t __attribute__ ((__mode__ (__HI__)));
typedef int int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int uint32_t __attribute__ ((__mode__ (__SI__)));

typedef int int64_t __attribute__((__mode__(__DI__)));
typedef unsigned int uint64_t __attribute__((__mode__(__DI__)));
# 142 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/stdint.h" 3
typedef int16_t intptr_t;




typedef uint16_t uintptr_t;
# 159 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/stdint.h" 3
typedef int8_t int_least8_t;




typedef uint8_t uint_least8_t;




typedef int16_t int_least16_t;




typedef uint16_t uint_least16_t;




typedef int32_t int_least32_t;




typedef uint32_t uint_least32_t;







typedef int64_t int_least64_t;






typedef uint64_t uint_least64_t;
# 213 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/stdint.h" 3
typedef int8_t int_fast8_t;




typedef uint8_t uint_fast8_t;




typedef int16_t int_fast16_t;




typedef uint16_t uint_fast16_t;




typedef int32_t int_fast32_t;




typedef uint32_t uint_fast32_t;







typedef int64_t int_fast64_t;






typedef uint64_t uint_fast64_t;
# 273 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/stdint.h" 3
typedef int64_t intmax_t;




typedef uint64_t uintmax_t;
# 38 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/inttypes.h" 2 3
# 77 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/inttypes.h" 3
typedef int32_t int_farptr_t;



typedef uint32_t uint_farptr_t;
# 127 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/sfr_defs.h" 2 3
# 100 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 2 3
# 274 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 3
# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/iotn2313.h" 1 3
# 275 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 2 3
# 334 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 3
# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/portpins.h" 1 3
# 335 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 2 3

# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/common.h" 1 3
# 337 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 2 3

# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/version.h" 1 3
# 339 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 2 3


# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/fuse.h" 1 3
# 234 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/fuse.h" 3
typedef struct
{
    unsigned char low;
    unsigned char high;
    unsigned char extended;
} __fuse_t;
# 342 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 2 3


# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/lock.h" 1 3
# 345 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/io.h" 2 3
# 103 "main.c" 2
# 1 "/usr/lib/gcc/avr/4.3.2/../../../../avr/include/avr/interrupt.h" 1 3
# 104 "main.c" 2
# 1 "../usbtiny/usb.h" 1
# 13 "../usbtiny/usb.h"
typedef unsigned char byte_t;
typedef unsigned int uint_t;


extern void usb_init ( void );
extern void usb_poll ( void );


extern void crc ( byte_t* data, byte_t len );


extern byte_t usb_setup ( byte_t data[8] );
extern void usb_out ( byte_t* data, byte_t len );
extern byte_t usb_in ( byte_t* data, byte_t len );
# 105 "main.c" 2
# 117 "main.c"
enum
{

 USBTINY_ECHO,

 IGORPLUG_CLEAR,
 IGORPLUG_READ,

 LCD_INSTR = 20,
 LCD_DATA,
};

static byte_t inpos = 0xff;
static byte_t edges;
static struct
{
 byte_t length;
 byte_t count;
 byte_t offset;
 byte_t data[35];
} ir;
# 166 "main.c"
__attribute__((signal,naked))
extern void __vector_3 ( void )
{
 static uint_t prev;
 uint_t stamp;
 byte_t delta;
 byte_t e;

 asm volatile(
  "push	r23\n"
  "in	r23,__SREG__\n"
  "push	r18\n"
  "push	r19\n"
  "push	r24\n"
  "push	r25\n"
 :: );
 stamp = (*(volatile uint16_t *)((0x24) + 0x20));
 (*(volatile uint8_t *)((0x39) + 0x20)) = 0;
 (*(volatile uint8_t *)((0x2E) + 0x20)) ^= (1 << (6));
 __asm__ __volatile__ ("sei" ::);
 (*(volatile uint8_t *)((0x12) + 0x20)) |= (1 << (5));
 asm volatile(
  "push	r20\n"
  "push	r21\n"
  "push	r30\n"
  "push	r31\n"
 :: );
 delta = (stamp - prev + (1 << (10 -3-1))) >> (10 -3);
 asm volatile("" : : "r"(delta) );
 prev = stamp;
 (*(volatile uint16_t *)((0x2A) + 0x20)) = stamp + 12L * 10500 / 8;
 __asm__ __volatile__ ("cli" ::);
 e = edges;
 if ( e != 0xff )
 {
  if ( e > 35 )
  {
   e -= 16;
  }
  if ( inpos == 0xff )
  {
   ir.length = 0;
   if ( e > 0 )
   {
    ir.data[e - 1] = delta;
   }
  }
  edges = e + 1;
 }
 __asm__ __volatile__ ("sei" ::);
 asm volatile("nop");
 asm volatile(
  "pop	r31\n"
  "pop	r30\n"
  "pop	r21\n"
  "pop	r20\n"
 :: );
 __asm__ __volatile__ ("cli" ::);
 (*(volatile uint8_t *)((0x39) + 0x20)) = (1 << (6)) | (1 << (3));
 asm volatile(
  "pop	r25\n"
  "pop	r24\n"
  "pop	r19\n"
  "pop	r18\n"
  "out	__SREG__,r23\n"
  "pop	r23\n"
  "reti\n"
 :: );
}




__attribute__((signal))
extern void __vector_4 ( void )
{
 (*(volatile uint8_t *)((0x39) + 0x20)) = 0;
 __asm__ __volatile__ ("sei" ::);
 (*(volatile uint8_t *)((0x12) + 0x20)) &= ~(1 << (5));
 __asm__ __volatile__ ("cli" ::);
 if ( edges >= 4
  && edges != 0xff
  && inpos == 0xff
  )
 {
  ir.count++;
  ir.length = edges - 1;
 }
 edges = 0;
 __asm__ __volatile__ ("sei" ::);
 (*(volatile uint8_t *)((0x2E) + 0x20)) &= ~(1 << (6));
 __asm__ __volatile__ ("cli" ::);
 (*(volatile uint8_t *)((0x39) + 0x20)) = (1 << (6)) | (1 << (3));
}




static void ir_init ( void )
{
 (*(volatile uint8_t *)((0x11) + 0x20)) |= (1 << (5));
 (*(volatile uint8_t *)((0x2E) + 0x20)) = (1 << (7))
        | (1 << (1));
 (*(volatile uint8_t *)((0x39) + 0x20)) = (1 << (6))
        | (1 << (3));
}





static void lcd_delay100u ( byte_t count )
{
 asm volatile(
  "0:	ldi	r25, 240\n"
  "1:	rjmp	2f\n"
  "2:	dec	r25\n"
  "	brne	1b\n"
  "	dec	r24\n"
  "	brne	0b\n"
 );
}




static void lcd_write4 ( byte_t data )
{
 (*(volatile uint8_t *)((0x18) + 0x20)) = ((*(volatile uint8_t *)((0x18) + 0x20)) & ~ (0xf << 0)) | (data << 0);
 (*(volatile uint8_t *)((0x18) + 0x20)) |= (1 << 6);
 (*(volatile uint8_t *)((0x17) + 0x20)) = (1 << 4) | (1 << 5) | (1 << 6) | (0xf << 0);
 (*(volatile uint8_t *)((0x18) + 0x20)) &= ~ (1 << 6);
 (*(volatile uint8_t *)((0x17) + 0x20)) = (1 << 4) | (1 << 5) | (1 << 6);
}




static byte_t lcd_read4 ( void )
{
 byte_t save;
 byte_t data;

 save = (*(volatile uint8_t *)((0x18) + 0x20));
 (*(volatile uint8_t *)((0x18) + 0x20)) = (1 << 5);
 (*(volatile uint8_t *)((0x18) + 0x20)) |= (1 << 6);
 asm volatile("rjmp 0f\n0:");
 data = ((*(volatile uint8_t *)((0x16) + 0x20)) & (0xf << 0)) >> 0;
 (*(volatile uint8_t *)((0x18) + 0x20)) = save;
 return data;
}




static void lcd_write ( byte_t b )
{
 byte_t h;

 do
 {
  h = lcd_read4();
  (void) lcd_read4();
 } while ( h & 0x08 );
 lcd_write4( b >> 4 );
 lcd_write4( b & 15 );
}




static void lcd_init ( void )
{
 (*(volatile uint8_t *)((0x17) + 0x20)) = (1 << 4) | (1 << 5) | (1 << 6);
 (*(volatile uint8_t *)((0x18) + 0x20)) = 0;

 lcd_write4( 3 );
 lcd_delay100u( 41 );
 lcd_write4( 3 );
 lcd_delay100u( 1 );
 lcd_write( 0x32 );
 lcd_write( 0x28 );
 lcd_write( 0x01 );
 lcd_write( 0x06 );
 lcd_write( 0x0c );
}





extern byte_t usb_setup ( byte_t data[8] )
{
 byte_t req;
 byte_t r;

 r = 0;


 req = data[1];
 if ( req == USBTINY_ECHO )
 {
  r = 8;
 }


 if ( req == IGORPLUG_CLEAR )
 {
  ir.length = 0;
  inpos = 0xff;
 }
 if ( req == IGORPLUG_READ )
 {
  __asm__ __volatile__ ("cli" ::);
  if ( ir.length > 0 )
  {
   inpos = data[4];
   r = 0xff;
  }
  else
  {
   data[0] = 0;
   r = 1;
  }
  __asm__ __volatile__ ("sei" ::);
 }


 if ( req == LCD_INSTR )
 {
  (*(volatile uint8_t *)((0x18) + 0x20)) &= ~ (1 << 4);
 }
 if ( req == LCD_DATA )
 {
  (*(volatile uint8_t *)((0x18) + 0x20)) |= (1 << 4);
 }

 return r;
}




extern byte_t usb_in ( byte_t* data, byte_t len )
{
 byte_t n;
 byte_t max;

 max = ir.length + 3;
 n = 0;
 while ( n < len )
 {
  if ( inpos >= max )
  {
   __asm__ __volatile__ ("cli" ::);
   if ( edges )
   {
    edges = 0xff;
   }
   inpos = 0xff;
   __asm__ __volatile__ ("sei" ::);
   break;
  }
  data[n++] = (& ir.length)[inpos++];
 }
 return n;
}




extern void usb_out ( byte_t* data, byte_t len )
{

 while ( len )
 {
  lcd_write( *data++ );
  len--;
 }

}




__attribute__((naked))
extern int main ( void )
{
 (*(volatile uint8_t *)((0x12) + 0x20)) |= (1 << (3));
 (*(volatile uint8_t *)((0x11) + 0x20)) |= (1 << (3));

 lcd_init();

 usb_init();
 ir_init();
 for ( ;; )
 {
  usb_poll();
 }
 return 0;
}
Comment 1 Eric Weddington 2009-01-24 16:15:32 UTC
This looks like a duplicate of bug #34299.
Comment 2 Charles Lindsay 2009-01-24 21:43:58 UTC
As with #34299, if you move the __attribute__s to the function's prototype (creating one if necessary) and remove them from the definition, the ICE goes away.
Comment 3 Eric Weddington 2009-01-24 23:35:03 UTC
Resolving as duplicate.

*** This bug has been marked as a duplicate of 34299 ***