Up to now observed only with compile option -g. Under the hoods possibly related to pr67542. $ cat z1.f90 program p type t integer :: a integer :: b(0) end type type(t), parameter :: z = t(1, [2]) print *, z end $ gfortran-6 -g -c z1.f90 internal compiler error: in native_encode_initializer, at dwarf2out.c:17767 $ gfortran-7-20160501 -g z1.f90 internal compiler error: in native_encode_initializer, at dwarf2out.c:17768 0x881dc0 native_encode_initializer ../../gcc/dwarf2out.c:17768 0x881982 native_encode_initializer ../../gcc/dwarf2out.c:17810 0x88ce15 tree_add_const_value_attribute ../../gcc/dwarf2out.c:17852 0x89aaef gen_const_die ../../gcc/dwarf2out.c:21258 0x89aaef gen_decl_die ../../gcc/dwarf2out.c:23404 0x89b82e dwarf2out_decl ../../gcc/dwarf2out.c:23954 0x8b2fc8 dwarf2out_early_global_decl ../../gcc/dwarf2out.c:23627 0x6f9d3b do_traverse_symtree ../../gcc/fortran/symbol.c:3817 0x73eb65 gfc_generate_function_code(gfc_namespace*) ../../gcc/fortran/trans-decl.c:6328 0x6cabc0 translate_all_program_units ../../gcc/fortran/parse.c:5613 0x6cabc0 gfc_parse_file() ../../gcc/fortran/parse.c:5819 0x70ca32 gfc_be_parse_file ../../gcc/fortran/f95-lang.c:201
Whereas, these variants compile without problems : $ cat z2.f90 program p type t integer :: b(0) end type type(t), parameter :: z = t([2]) print *, z end $ cat z3.f90 program p type t integer :: a integer :: b(0) end type type(t), parameter :: z = t(1, 2) print *, z end
The code compiles with 4.6.4 and 4.7.3, but gives an ICE starting with 4.8 up to trunk (7.0). The change occurred between revision r188694 (2012-06-16, compiles) and r188914 (2012-06-24, ICE). The only change of dwarf2out.c in this range is r188874.
I think this is a corner-case of native_encode_initializer not handling zero-sized FIELD_DECLs. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 235859) +++ gcc/dwarf2out.c (working copy) @@ -17806,7 +17806,7 @@ native_encode_initializer (tree init, un fieldsize = tree_to_shwi (DECL_SIZE_UNIT (field)); pos = int_byte_position (field); gcc_assert (pos + fieldsize <= size); - if (val + if (val && fieldsize != 0 && !native_encode_initializer (val, array + pos, fieldsize)) return false; } fixes it.
Fixed on trunk sofar.
Author: rguenth Date: Fri May 6 07:44:22 2016 New Revision: 235944 URL: https://gcc.gnu.org/viewcvs?rev=235944&root=gcc&view=rev Log: 2016-05-06 Richard Biener <rguenther@suse.de> PR middle-end/70931 * dwarf2out.c (native_encode_initializer): Skip zero-sized fields. * gfortran.dg/pr70931.f90: New testcase. Added: trunk/gcc/testsuite/gfortran.dg/pr70931.f90 Modified: trunk/gcc/ChangeLog trunk/gcc/dwarf2out.c trunk/gcc/testsuite/ChangeLog
Author: rguenth Date: Fri May 13 13:22:42 2016 New Revision: 236210 URL: https://gcc.gnu.org/viewcvs?rev=236210&root=gcc&view=rev Log: 2016-05-13 Richard Biener <rguenther@suse.de> Backport from mainline 2016-04-27 Richard Biener <rguenther@suse.de> PR ipa/70760 * tree-ssa-structalias.c (find_func_aliases_for_call): Use aggregate_value_p to determine if a function result is returned by reference. * g++.dg/ipa/ipa-pta-2.C: New testcase. * gcc.dg/ipa/ipa-pta-1.c: Adjust. 2016-05-06 Richard Biener <rguenther@suse.de> PR middle-end/70931 * dwarf2out.c (native_encode_initializer): Skip zero-sized fields. * gfortran.dg/pr70931.f90: New testcase. 2016-05-06 Richard Biener <rguenther@suse.de> PR middle-end/70941 * fold-const.c (split_tree): Always convert to the original type before negating. * gcc.dg/torture/pr70941.c: New testcase. 2016-05-06 Jakub Jelinek <jakub@redhat.com> PR middle-end/70941 * gcc.dg/torture/pr70941.c (abort): Remove prototype. (a, b, c, d): Change type from char to signed char. (main): Compare against (signed char) -1634678893 instead of hardcoded -109. Use __builtin_abort instead of abort. Added: branches/gcc-6-branch/gcc/testsuite/g++.dg/ipa/ipa-pta-2.C branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr70941.c branches/gcc-6-branch/gcc/testsuite/gfortran.dg/pr70931.f90 Modified: branches/gcc-6-branch/gcc/ChangeLog branches/gcc-6-branch/gcc/dwarf2out.c branches/gcc-6-branch/gcc/fold-const.c branches/gcc-6-branch/gcc/testsuite/ChangeLog branches/gcc-6-branch/gcc/tree-ssa-structalias.c
Author: rguenth Date: Fri May 20 08:51:06 2016 New Revision: 236497 URL: https://gcc.gnu.org/viewcvs?rev=236497&root=gcc&view=rev Log: 2016-05-20 Richard Biener <rguenther@suse.de> Backport from mainline 2016-02-01 Bin Cheng <bin.cheng@arm.com> PR tree-optimization/67921 * fold-const.c (split_tree): New parameters. Convert pointer type variable part to proper type before negating. (fold_binary_loc): Pass new arguments to split_tree. * c-c++-common/ubsan/pr67921.c: New test. 2016-05-06 Richard Biener <rguenther@suse.de> PR middle-end/70941 * fold-const.c (split_tree): Always convert to the original type before negating. * gcc.dg/torture/pr70941.c: New testcase. 2016-05-06 Jakub Jelinek <jakub@redhat.com> PR middle-end/70941 * gcc.dg/torture/pr70941.c (abort): Remove prototype. (a, b, c, d): Change type from char to signed char. (main): Compare against (signed char) -1634678893 instead of hardcoded -109. Use __builtin_abort instead of abort. 2016-05-06 Richard Biener <rguenther@suse.de> PR middle-end/70931 * dwarf2out.c (native_encode_initializer): Skip zero-sized fields. * gfortran.dg/pr70931.f90: New testcase. 2016-04-14 Richard Biener <rguenther@suse.de> PR tree-optimization/70623 * tree-ssa-pre.c (changed_blocks): Make global ... (compute_antic): ... local here. Move and fix worklist handling here. Do not clear EDGE_DFS_BACK. (compute_antic_aux): Add dumping for MAX assumed succs. Remove worklist handling, dump when ANTIC_IN changed. (compute_partial_antic_aux): Remove worklist handling. (init_pre): Do not compute post dominators. Add a comment about the CFG order chosen. (fini_pre): Do not free post dominators. * gcc.dg/torture/pr70623.c: New testcase. * gcc.dg/torture/pr70623-2.c: Likewise. 2016-04-25 Richard Biener <rguenther@suse.de> PR tree-optimization/70780 * tree-ssa-pre.c (compute_antic_aux): Also return true if the block wasn't visited yet. (compute_antic): Mark blocks with abnormal preds as visited as they have a final empty antic-in solution already. * gcc.dg/torture/pr70780.c: New testcase. Added: branches/gcc-5-branch/gcc/testsuite/c-c++-common/ubsan/pr67921.c branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr70623-2.c branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr70623.c branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr70780.c branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr70941.c branches/gcc-5-branch/gcc/testsuite/gfortran.dg/pr70931.f90 Modified: branches/gcc-5-branch/gcc/ChangeLog branches/gcc-5-branch/gcc/dwarf2out.c branches/gcc-5-branch/gcc/fold-const.c branches/gcc-5-branch/gcc/testsuite/ChangeLog branches/gcc-5-branch/gcc/tree-ssa-pre.c
Fixed.
Author: rguenth Date: Thu Jul 7 11:46:08 2016 New Revision: 238087 URL: https://gcc.gnu.org/viewcvs?rev=238087&root=gcc&view=rev Log: 2016-07-07 Richard Biener <rguenther@suse.de> Backport from mainline 2016-04-04 Richard Biener <rguenther@suse.de> PR rtl-optimization/70484 * rtl.h (canon_output_dependence): Declare. * alias.c (canon_output_dependence): New function. * dse.c (record_store): Use canon_output_dependence rather than canon_true_dependence. * gcc.dg/torture/pr70484.c: New testcase. 2016-06-08 Richard Biener <rguenther@suse.de> PR tree-optimization/71452 * tree-ssa.c (non_rewritable_lvalue_p): Make sure that the type used for the SSA rewrite has enough precision to cover the dynamic type of the location. * gcc.dg/torture/pr71452.c: New testcase. 2016-05-06 Richard Biener <rguenther@suse.de> PR middle-end/70931 * dwarf2out.c (native_encode_initializer): Skip zero-sized fields. * gfortran.dg/pr70931.f90: New testcase. 2016-03-01 Richard Biener <rguenther@suse.de> PR middle-end/70022 * fold-const.c (fold_indirect_ref_1): Fix range checking for vector BIT_FIELD_REF extract. * gcc.dg/pr70022.c: New testcase. Added: branches/gcc-4_9-branch/gcc/testsuite/g++.dg/torture/pr71452.C branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr70022.c branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr70484.c branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr71452.c branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/pr70931.f90 Modified: branches/gcc-4_9-branch/gcc/ChangeLog branches/gcc-4_9-branch/gcc/alias.c branches/gcc-4_9-branch/gcc/dse.c branches/gcc-4_9-branch/gcc/dwarf2out.c branches/gcc-4_9-branch/gcc/fold-const.c branches/gcc-4_9-branch/gcc/rtl.h branches/gcc-4_9-branch/gcc/testsuite/ChangeLog branches/gcc-4_9-branch/gcc/tree-ssa.c