Bug 82564 - ICE at -O1 and above: in assign_stack_temp_for_type, at function.c:783
Summary: ICE at -O1 and above: in assign_stack_temp_for_type, at function.c:783
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2017-10-16 14:39 UTC by Zhendong Su
Modified: 2019-08-30 11:26 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2017-10-16 14:39:42 UTC
This seems to affect at least as early as 4.8.x. 


$ gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/home/su/software/tmp/gcc/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/home/su/software/tmp/gcc/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 8.0.0 20171016 (experimental) [trunk revision 253785] (GCC) 
$ 
$ gcctk -O0 small.c
$      
$ gcctk -O1 small.c
during RTL pass: expand
small.c: In function ‘main’:
small.c:17:5: internal compiler error: in assign_stack_temp_for_type, at function.c:783
   a = f ();
   ~~^~~~~~
0x973b2b assign_stack_temp_for_type(machine_mode, long, tree_node*)
	../../gcc-source-trunk/gcc/function.c:783
0x973be3 assign_temp(tree_node*, int, int)
	../../gcc-source-trunk/gcc/function.c:999
0x7d4914 expand_call(tree_node*, rtx_def*, int)
	../../gcc-source-trunk/gcc/calls.c:3135
0x907710 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	../../gcc-source-trunk/gcc/expr.c:10869
0x91a63d expand_normal
	../../gcc-source-trunk/gcc/expr.h:282
0x91a63d store_field
	../../gcc-source-trunk/gcc/expr.c:6843
0x916631 expand_assignment(tree_node*, tree_node*, bool)
	../../gcc-source-trunk/gcc/expr.c:5170
0x7e95aa expand_call_stmt
	../../gcc-source-trunk/gcc/cfgexpand.c:2664
0x7e95aa expand_gimple_stmt_1
	../../gcc-source-trunk/gcc/cfgexpand.c:3585
0x7e95aa expand_gimple_stmt
	../../gcc-source-trunk/gcc/cfgexpand.c:3751
0x7eb442 expand_gimple_basic_block
	../../gcc-source-trunk/gcc/cfgexpand.c:5754
0x7f0e46 execute
	../../gcc-source-trunk/gcc/cfgexpand.c:6361
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.
$ 


------------------------------------------


int main ()
{
  int t = 8;

  typedef struct
  {
    char v[t];
  } B; 

  B a, b;

  B __attribute__ ((noinline)) f ()
  {
    return b; 
  }

  a = f ();

  return 0;
}
Comment 1 Andrew Pinski 2017-10-16 16:13:11 UTC
There might be a dup of this bug already filed too.
Comment 2 Andrew Pinski 2017-10-16 16:16:47 UTC
Related to PR 8081.
Comment 3 Jakub Jelinek 2019-01-05 11:14:45 UTC
Author: jakub
Date: Sat Jan  5 11:14:12 2019
New Revision: 267595

URL: https://gcc.gnu.org/viewcvs?rev=267595&root=gcc&view=rev
Log:
	PR middle-end/82564
	PR target/88620
	* expr.c (expand_assignment): For calls returning VLA structures
	if to_rtx is not a MEM, force it into a stack temporary.

	* gcc.dg/nested-func-12.c: New test.
	* gcc.c-torture/compile/pr82564.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr82564.c
    trunk/gcc/testsuite/gcc.dg/nested-func-12.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Jakub Jelinek 2019-01-05 12:20:11 UTC
Fixed on the trunk.
Comment 5 Jakub Jelinek 2019-01-08 10:34:46 UTC
Author: jakub
Date: Tue Jan  8 10:34:14 2019
New Revision: 267720

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

	PR middle-end/82564
	PR target/88620
	* expr.c (expand_assignment): For calls returning VLA structures
	if to_rtx is not a MEM, force it into a stack temporary.

	* gcc.dg/nested-func-12.c: New test.
	* gcc.c-torture/compile/pr82564.c: New test.

Added:
    branches/gcc-8-branch/gcc/testsuite/gcc.c-torture/compile/pr82564.c
    branches/gcc-8-branch/gcc/testsuite/gcc.dg/nested-func-12.c
Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/expr.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2019-08-30 11:26:33 UTC
Author: jakub
Date: Fri Aug 30 11:26:01 2019
New Revision: 275085

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

	PR middle-end/82564
	PR target/88620
	* expr.c (expand_assignment): For calls returning VLA structures
	if to_rtx is not a MEM, force it into a stack temporary.

	* gcc.dg/nested-func-12.c: New test.
	* gcc.c-torture/compile/pr82564.c: New test.

Added:
    branches/gcc-7-branch/gcc/testsuite/gcc.c-torture/compile/pr82564.c
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/nested-func-12.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/expr.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog