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

            Bug ID: 105310
           Summary: ICE when UNION is after the 8th field in a DEC
                    STRUCTURE with -finit-derived -finit-local-zero
           Product: gcc
           Version: 7.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: foreese at gcc dot gnu.org
  Target Milestone: ---

Created attachment 52833
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52833&action=edit
Test case exhibiting the ICE

Consider:

$ cat testunion.for
      PROGRAM TESTU
        IMPLICIT NONE
        STRUCTURE /FOO/
          INTEGER(4) :: a,b,c,d,e,f,g,h
          UNION
          MAP
          ENDMAP
          ENDUNION
        ENDSTRUCTURE
        RECORD /FOO/ bar
        bar.a = 1
      END

$ gfortran -O0 -c -ffixed-form -finit-local-zero -finit-derived -fdec-structure
testunion.for
testunion.for:15:0:

       end

internal compiler error: Segmentation fault
0xa72a2f crash_signal
        /data/gcc-7.4.0/gcc/toplev.c:337
0xcb6a54 compute_reloc_for_constant(tree_node*)
        /data/gcc-7.4.0/gcc/varasm.c:4120
0xcb6b5c compute_reloc_for_constant(tree_node*)
        /data/gcc-7.4.0/gcc/varasm.c:4174
0xcbc802 get_variable_section(tree_node*, bool)
        /data/gcc-7.4.0/gcc/varasm.c:1148
0xcc0cb7 assemble_variable(tree_node*, int, int, int)
        /data/gcc-7.4.0/gcc/varasm.c:2225
0xcc4ce2 varpool_node::assemble_decl()
        /data/gcc-7.4.0/gcc/varpool.c:588
0x7426fc output_in_order
        /data/gcc-7.4.0/gcc/cgraphunit.c:2289
0x742ac3 symbol_table::compile()
        /data/gcc-7.4.0/gcc/cgraphunit.c:2530
0x744b16 symbol_table::compile()
        /data/gcc-7.4.0/gcc/cgraphunit.c:2629
0x744b16 symbol_table::finalize_compilation_unit()
        /data/gcc-7.4.0/gcc/cgraphunit.c:2626
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


ICE occurs with 7.4 and higher, where the -fdec-structure and -finit-derived
options were introduced.

The ICE occurs at -O0 but not for higher optimization levels. The ICE occurs
only when there are (8*2^n) fields preceding the union, regardless of which
fields are in the union.

Reply via email to