Bug 78849 - ICE on initialization of global struct containing __int20 array at varasm.c:4968
Summary: ICE on initialization of global struct containing __int20 array at varasm.c:4968
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 6.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-18 01:26 UTC by Andrew Wygle
Modified: 2018-11-28 11:18 UTC (History)
0 users

See Also:
Host:
Target: msp430-elf
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Wygle 2016-12-18 01:26:32 UTC
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
Comment 1 Jozef Lawrynowicz 2017-04-24 11:38:49 UTC
Patch submitted https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01030.html
Comment 2 Jeffrey A. Law 2018-05-23 22:34:21 UTC
Author: law
Date: Wed May 23 22:33:36 2018
New Revision: 260627

URL: https://gcc.gnu.org/viewcvs?rev=260627&root=gcc&view=rev
Log:
	PR target/78849
	* gcc/tree.c (build_common_tree_nodes): Dont set TYPE_SIZE for __intN
	types.

	PR target/78849
	* gcc.target/msp430/msp430.exp: Remove -pedantic-errors from
	DEFAULT_CFLAGS.
	* gcc.target/msp430/pr78849.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/msp430/pr78849.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/msp430/msp430.exp
    trunk/gcc/tree.c
Comment 3 Martin Liška 2018-11-19 14:43:25 UTC
Jeff: Can you please update Known to work?
Comment 4 Jozef Lawrynowicz 2018-11-28 11:06:36 UTC
This bug is fixed, but I cannot close the PR, could someone else please resolve it?
Comment 5 Martin Liška 2018-11-28 11:18:49 UTC
Sure, closing..