Bug 91221 - [10 Regression] ICE in get_int_cst_ext_nunits, at tree.c:1299 since r273548
Summary: [10 Regression] ICE in get_int_cst_ext_nunits, at tree.c:1299 since r273548
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: 10.0
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2019-07-22 07:53 UTC by Martin Liška
Modified: 2019-07-22 11:19 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 9.1.0
Known to fail: 10.0
Last reconfirmed: 2019-07-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2019-07-22 07:53:00 UTC
Following is causing ICE:

$ cat ice.ii
void printf(...);
struct A {
  A() : bar_(), dbar_() {
    for (int i;; i++)
      printf(i, bar_[i]);
  }
  int bar_[5];
  double dbar_[5];
};
void fn1() { A a; }

$ g++ -fno-ipa-pure-const -O2 -fpack-struct ice.ii -c
ice.ii: In constructor ‘A::A()’:
ice.ii:3:23: warning: taking address of packed member of ‘A’ may result in an unaligned pointer value [-Waddress-of-packed-member]
    3 |   A() : bar_(), dbar_() {
      |                       ^
ice.ii:3:23: warning: taking address of packed member of ‘A’ may result in an unaligned pointer value [-Waddress-of-packed-member]
during GIMPLE pass: fre
ice.ii: In function ‘void fn1()’:
ice.ii:10:6: internal compiler error: in get_int_cst_ext_nunits, at tree.c:1299
   10 | void fn1() { A a; }
      |      ^~~
0x7f8e6d get_int_cst_ext_nunits
	/home/marxin/Programming/gcc/gcc/tree.c:1299
0x1283c88 wide_int_to_tree_1
	/home/marxin/Programming/gcc/gcc/tree.c:1517
0xfb555c set_min_and_max_values_for_integral_type(tree_node*, int, signop)
	/home/marxin/Programming/gcc/gcc/stor-layout.c:2791
0xfbbde7 set_min_and_max_values_for_integral_type(tree_node*, int, signop)
	/home/marxin/Programming/gcc/gcc/stor-layout.c:2787
0xfbbde7 fixup_signed_type(tree_node*)
	/home/marxin/Programming/gcc/gcc/stor-layout.c:2805
0x128799f build_nonstandard_integer_type(unsigned long, int)
	/home/marxin/Programming/gcc/gcc/tree.c:8220
0x117e1b2 vn_walk_cb_data::push_partial_def(pd_data const&, tree_node*, long)
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:1852
0x117e1b2 vn_walk_cb_data::push_partial_def(pd_data const&, tree_node*, long)
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:1739
0x117f38e vn_reference_lookup_3
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:2519
0x10c507c walk_non_aliased_vuses(ao_ref*, tree_node*, bool, void* (*)(ao_ref*, tree_node*, void*), void* (*)(ao_ref*, tree_node*, void*, bool*), tree_node* (*)(tree_node*), unsigned int&, void*)
	/home/marxin/Programming/gcc/gcc/tree-ssa-alias.c:3377
0x1176fb3 vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind, vn_reference_s**, bool, tree_node**)
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:3108
0x1181586 visit_reference_op_load
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:4466
0x1181586 visit_stmt
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:4883
0x1183483 process_bb
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:6506
0x1184786 do_rpo_vn
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:7137
0x1185f0a execute
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:7286
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.
Comment 1 Martin Liška 2019-07-22 07:55:26 UTC
One another test-case:

$ cat ice.f
      parameternumlev=3,numoblev=1000
      integer i_otyp(numoblev,numlev) 
      logical l_numob(numoblev,numlev)
      do ixe=1,numoblev
         do iye=1,numlev
            i_otyp(ixe,iye)=0
            l_numob(ixe,iye)=.false.
         enddo
      enddo
      do i=1,m
         do j=1,n
            if (l_numob(i,j)) then
               write(0) i_otyp
            endif
         enddo
      enddo
      end
$ gcc -Ofast -ftrapv ice.f -c
ice.f:1:15:

    1 |       parameternumlev=3,numoblev=1000
      |               1
Warning: Legacy Extension: PARAMETER without '()' at (1)
during GIMPLE pass: fre
ice.f:1:0:

    1 |       parameternumlev=3,numoblev=1000
      | 
internal compiler error: in smallest_mode_for_size, at stor-layout.c:355
0xded295 smallest_mode_for_size(poly_int<1u, unsigned long>, mode_class)
	/home/marxin/Programming/gcc/gcc/stor-layout.c:355
0xded295 smallest_mode_for_size(poly_int<1u, unsigned long>, mode_class)
	/home/marxin/Programming/gcc/gcc/stor-layout.c:344
0xdf23b2 smallest_int_mode_for_size(poly_int<1u, unsigned long>)
	/home/marxin/Programming/gcc/gcc/machmode.h:838
0xdf23b2 layout_type(tree_node*)
	/home/marxin/Programming/gcc/gcc/stor-layout.c:2326
0x10be9f4 build_nonstandard_integer_type(unsigned long, int)
	/home/marxin/Programming/gcc/gcc/tree.c:8218
0xfb5032 vn_walk_cb_data::push_partial_def(pd_data const&, tree_node*, long)
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:1852
0xfb5032 vn_walk_cb_data::push_partial_def(pd_data const&, tree_node*, long)
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:1739
0xfb620e vn_reference_lookup_3
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:2519
0xefbefc walk_non_aliased_vuses(ao_ref*, tree_node*, bool, void* (*)(ao_ref*, tree_node*, void*), void* (*)(ao_ref*, tree_node*, void*, bool*), tree_node* (*)(tree_node*), unsigned int&, void*)
	/home/marxin/Programming/gcc/gcc/tree-ssa-alias.c:3377
0xfade33 vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind, vn_reference_s**, bool, tree_node**)
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:3108
0xfb8406 visit_reference_op_load
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:4466
0xfb8406 visit_stmt
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:4883
0xfba303 process_bb
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:6506
0xfbb606 do_rpo_vn
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:7137
0xfbcd8a execute
	/home/marxin/Programming/gcc/gcc/tree-ssa-sccvn.c:7286
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.
Comment 2 Richard Biener 2019-07-22 08:57:36 UTC
Mine.
Comment 3 Richard Biener 2019-07-22 11:19:02 UTC
Fixed.
Comment 4 Richard Biener 2019-07-22 11:19:26 UTC
Author: rguenth
Date: Mon Jul 22 11:18:55 2019
New Revision: 273667

URL: https://gcc.gnu.org/viewcvs?rev=273667&root=gcc&view=rev
Log:
2019-07-22  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/91221
	* tree-ssa-sccvn.c (vn_reference_lookup_3): Appropriately
	restrict partial-def handling of empty constructors and
	memset to refs with known offset.

	* g++.dg/pr91221.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/pr91221.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-sccvn.c