Bug 89187 - [7 Regression] ICE in initialize_argument_information, at calls.c:2023
Summary: [7 Regression] ICE in initialize_argument_information, at calls.c:2023
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.0
: P2 normal
Target Milestone: 7.5
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2019-02-04 10:58 UTC by Martin Liška
Modified: 2019-08-30 13:38 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: s390x-linux-gnu
Build:
Known to work:
Known to fail: 6.4.0, 7.3.0, 8.2.0, 9.0
Last reconfirmed: 2019-02-04 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-02-04 10:58:15 UTC
Following code is causing ICE:

$ cat ice.C
template <typename a, int b> struct c {
  typedef a __attribute__((vector_size(b))) d;
};
template <typename a, int b> using e = typename c<a, b>::d;
template <typename a> using f = e<a, 4>;
struct g {
  g(f<int> h) : i{h[3]} {}
  g j() { return i; }
  f<int> i;
};
struct {
  g k();
} l;
class m {
  void n() const;
};
void m::n() const { l.k().j(); }

$ s390x-linux-gnu-gcc ice.C -fno-tree-ccp -fno-tree-sra -flive-patching=inline-only-static -Os
ice.C:12:5: warning: ‘g<unnamed struct>::k()’ used but never defined
   12 |   g k();
      |     ^
during RTL pass: expand
ice.C: In constructor ‘g::g(f<int>)’:
ice.C:7:26: internal compiler error: in initialize_argument_information, at calls.c:2023
    7 |   g(f<int> h) : i{h[3]} {}
      |                          ^
0x580afb initialize_argument_information
	/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-s390x/build/gcc/calls.c:2023
0x580afb expand_call(tree_node*, rtx_def*, int)
	/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-s390x/build/gcc/calls.c:3601
0x892cce expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-s390x/build/gcc/expr.c:11008
0x7a1921 expand_expr
	/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-s390x/build/gcc/expr.h:279
0x7a1921 expand_call_stmt
	/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-s390x/build/gcc/cfgexpand.c:2724
0x7a1921 expand_gimple_stmt_1
	/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-s390x/build/gcc/cfgexpand.c:3691
0x7a1921 expand_gimple_stmt
	/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-s390x/build/gcc/cfgexpand.c:3850
0x7a344f expand_gimple_basic_block
	/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-s390x/build/gcc/cfgexpand.c:5886
0x7a8396 execute
	/home/marxin/BIG/buildbot/buildworker/marxinbox-gcc-trunk-s390x/build/gcc/cfgexpand.c:6509
Comment 1 Martin Liška 2019-02-04 10:58:37 UTC
I'm bisecting that.
Comment 2 Martin Liška 2019-02-04 11:21:51 UTC
It's older, one can see it with:
$ s390x-linux-gnu-gcc ice.C -fno-tree-ccp -fno-tree-sra  -Os -fno-inline
Comment 3 Martin Liška 2019-02-04 11:28:29 UTC
It's at least as old as r235033, I'm leaving bisection..
Comment 4 Jakub Jelinek 2019-02-04 14:46:50 UTC
With a small adjustment and -std=c++0x -fno-tree-ccp -fno-tree-sra  -Os -fno-inline
template <typename a, int b> struct c {
  typedef a __attribute__((vector_size(b))) d;
};
template <typename a, int b> using e = typename c<a, b>::d;
template <typename a> using f = e<a, 4>;
struct g {
  g(f<int> h) : i{h[3]} {}
  g j() { return i; }
  f<int> i;
};
extern g gg;
struct {
  g k() { return gg; }
} l;
class m {
  void n() const;
};
void m::n() const { l.k().j(); }

it was accepted by r205706 and before (back to when it wasn't accepted because missing C++11 support) and r207203 already ICEs on it, don't have around anything in between.
Comment 5 Jakub Jelinek 2019-02-04 15:50:19 UTC
So, seems this is a thunk, and the vector type argument is marked addressable by convert_vector_to_array_for_subscript -> c_common_mark_addressable_vec because of the h[3].
Comment 6 Marek Polacek 2019-02-04 22:15:34 UTC
Fixing Assignee.
Comment 7 Jakub Jelinek 2019-02-05 22:28:56 UTC
Author: jakub
Date: Tue Feb  5 22:28:25 2019
New Revision: 268564

URL: https://gcc.gnu.org/viewcvs?rev=268564&root=gcc&view=rev
Log:
	PR c++/89187
	* optimize.c (maybe_thunk_body): Clear TREE_ADDRESSABLE on
	PARM_DECLs of the thunk.
	* lambda.c (maybe_add_lambda_conv_op): Likewise.

	* g++.dg/opt/pr89187.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr89187.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/lambda.c
    trunk/gcc/cp/optimize.c
    trunk/gcc/testsuite/ChangeLog
Comment 8 Jakub Jelinek 2019-02-05 23:05:01 UTC
Fixed on the trunk so far.
Comment 9 Jakub Jelinek 2019-02-07 14:58:02 UTC
Author: jakub
Date: Thu Feb  7 14:57:29 2019
New Revision: 268649

URL: https://gcc.gnu.org/viewcvs?rev=268649&root=gcc&view=rev
Log:
	Backported from mainline
	2019-02-05  Jakub Jelinek  <jakub@redhat.com>

	PR c++/89187
	* optimize.c (maybe_thunk_body): Clear TREE_ADDRESSABLE on
	PARM_DECLs of the thunk.
	* lambda.c (maybe_add_lambda_conv_op): Likewise.

	* g++.dg/opt/pr89187.C: New test.

Added:
    branches/gcc-8-branch/gcc/testsuite/g++.dg/opt/pr89187.C
Modified:
    branches/gcc-8-branch/gcc/cp/ChangeLog
    branches/gcc-8-branch/gcc/cp/lambda.c
    branches/gcc-8-branch/gcc/cp/optimize.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 10 Jakub Jelinek 2019-02-07 15:11:35 UTC
Fixed for 8.3+ too.
Comment 11 Jakub Jelinek 2019-08-30 11:44:29 UTC
Author: jakub
Date: Fri Aug 30 11:43:53 2019
New Revision: 275104

URL: https://gcc.gnu.org/viewcvs?rev=275104&root=gcc&view=rev
Log:
	Backported from mainline
	2019-02-05  Jakub Jelinek  <jakub@redhat.com>

	PR c++/89187
	* optimize.c (maybe_thunk_body): Clear TREE_ADDRESSABLE on
	PARM_DECLs of the thunk.
	* lambda.c (maybe_add_lambda_conv_op): Likewise.

	* g++.dg/opt/pr89187.C: New test.

Added:
    branches/gcc-7-branch/gcc/testsuite/g++.dg/opt/pr89187.C
Modified:
    branches/gcc-7-branch/gcc/cp/ChangeLog
    branches/gcc-7-branch/gcc/cp/lambda.c
    branches/gcc-7-branch/gcc/cp/optimize.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
Comment 12 Jakub Jelinek 2019-08-30 13:38:51 UTC
Fixed.