https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78849

            Bug ID: 78849
           Summary: ICE on initialization of global struct containing
                    __int20 array at varasm.c:4968
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: awygle at gmail dot com
  Target Milestone: ---

The following code (constructor_bug.i) produces an internal compiler error when
compiled for the msp430-elf target:

# 1 "constructor_bug.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "constructor_bug.c"

struct causes_problems {
  __int20 array[2];
  char value;
};

struct causes_problems instance = {
  {
    0,
    1,
  },
  0,
};

void main(void) {
  while(1);
}

% msp430-elf-gcc -msim constructor_bug.i
constructor_bug.c:17:1: internal compiler error: in
output_constructor_regular_field, at varasm.c:4968
 }
 ^
0xb06039 output_constructor_regular_field
        ../../gcc-6.2.0/gcc/varasm.c:4968
0xb06039 output_constructor
        ../../gcc-6.2.0/gcc/varasm.c:5276
0xb05254 assemble_variable_contents
        ../../gcc-6.2.0/gcc/varasm.c:2062
0xb0bdca assemble_variable(tree_node*, int, int, int)
        ../../gcc-6.2.0/gcc/varasm.c:2238
0xb0fadd varpool_node::assemble_decl()
        ../../gcc-6.2.0/gcc/varpool.c:582
0x600403 output_in_order
        ../../gcc-6.2.0/gcc/cgraphunit.c:2231
0x6006a3 symbol_table::compile()
        ../../gcc-6.2.0/gcc/cgraphunit.c:2468
0x6025d9 symbol_table::finalize_compilation_unit()
        ../../gcc-6.2.0/gcc/cgraphunit.c:2564
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

% msp430-elf-gcc -v
Using built-in specs.
COLLECT_GCC=msp430-elf-gcc
COLLECT_LTO_WRAPPER=/home/awygle/toolchain/install/libexec/gcc/msp430-elf/6.2.0/lto-wrapper
Target: msp430-elf
Configured with: ../gcc-6.2.0/configure
--prefix=/home/awygle/toolchain/install/ --target=msp430-elf --without-headers
--with-newlib --enable-languages=c,c++ -v
Thread model: single
gcc version 6.2.0 (GCC)


As far as I can tell this is a minimal test case, by which I mean that any of
the following prevents the error:

* Reducing the length of the array to 1
* Removing the "value" field from the struct
* Moving the array field to the end of the struct
* Not initializing the struct
* Moving the struct variable definition and initialization into the main()
function

I filed this under "target" but I suspect it would apply to any
non-byte-aligned __intN type - however, only one of those seems to exist right
now and it's in the msp430 target. I tried to reproduce this bug on the AVR
target using __int24 without success, but my avr-gcc version is 4.8.2 rather
than 6.2.

Thanks

Reply via email to