Bug 70931 - [4.9 Regression] ICE with -g in native_encode_initializer, bei dwarf2out.c:17768
Summary: [4.9 Regression] ICE with -g in native_encode_initializer, bei dwarf2out.c:17768
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 6.1.1
: P4 normal
Target Milestone: 4.9.4
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2016-05-03 19:32 UTC by Gerhard Steinmetz
Modified: 2016-07-07 11:46 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.6.4, 4.7.3, 5.4.0, 6.2.0, 7.0
Known to fail: 4.8.5, 4.9.3, 5.3.0, 6.1.0, 7.0
Last reconfirmed: 2016-05-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Steinmetz 2016-05-03 19:32:11 UTC
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
Comment 1 Gerhard Steinmetz 2016-05-03 19:33:14 UTC
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
Comment 2 Dominique d'Humieres 2016-05-03 19:53:37 UTC
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.
Comment 3 Richard Biener 2016-05-04 09:07:18 UTC
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.
Comment 4 Richard Biener 2016-05-06 07:44:44 UTC
Fixed on trunk sofar.
Comment 5 Richard Biener 2016-05-06 07:44:54 UTC
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
Comment 6 Richard Biener 2016-05-13 13:23:14 UTC
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
Comment 7 Richard Biener 2016-05-20 08:51:38 UTC
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
Comment 8 Richard Biener 2016-07-07 11:46:35 UTC
Fixed.
Comment 9 Richard Biener 2016-07-07 11:46:40 UTC
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