Bug 88394 - [8 Regression] g++ ICE (Segmentation fault) in insert_capture_proxy
Summary: [8 Regression] g++ ICE (Segmentation fault) in insert_capture_proxy
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.2.1
: P2 normal
Target Milestone: 8.4
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-12-06 15:46 UTC by Matthias Klose
Modified: 2020-02-26 17:59 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 7.4.0
Known to fail: 8.2.1, 9.0
Last reconfirmed: 2018-12-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2018-12-06 15:46:47 UTC
$ cat crash.cpp 
void crash_me(unsigned short sz)
{
  if (sz == 0) return;

  short iov[sz];
  auto fce = [&iv = iov](short value) { iv[0] = 0; };
  fce(1);
}

$ /usr/lib/gcc-snapshot/bin/g++ -c crash.cpp 
crash.cpp: In lambda function:
crash.cpp:6:37: internal compiler error: Segmentation fault
    6 |   auto fce = [&iv = iov](short value) { iv[0] = 0; };
      |                                     ^
Please submit a full bug report,
with preprocessed source if appropriate.

Program received signal SIGSEGV, Segmentation fault.
0x00000000009273a0 in insert_capture_proxy(tree_node*) ()
(gdb) bt
#0  0x00000000009273a0 in insert_capture_proxy(tree_node*) ()
#1  0x0000000000927e1e in ?? ()
#2  0x000000000092b0d8 in start_lambda_function(tree_node*, tree_node*) ()
#3  0x0000000000976a73 in ?? ()
#4  0x000000000097b1c3 in ?? ()
#5  0x000000000098887b in ?? ()
#6  0x0000000000965400 in ?? ()
#7  0x0000000000965bda in ?? ()
#8  0x0000000000966aa8 in ?? ()
#9  0x000000000096648e in ?? ()
#10 0x0000000000966a42 in ?? ()
#11 0x000000000096a870 in ?? ()
#12 0x000000000098eaca in ?? ()
#13 0x0000000000972953 in ?? ()
#14 0x000000000097449a in ?? ()
#15 0x0000000000974f2c in ?? ()
#16 0x0000000000975f09 in ?? ()
#17 0x0000000000975fe9 in ?? ()
#18 0x000000000098d7b6 in ?? ()
#19 0x000000000098e06c in ?? ()
#20 0x000000000098edca in ?? ()
#21 0x0000000000972953 in ?? ()
#22 0x0000000000995641 in ?? ()
#23 0x0000000000995dbd in c_parse_file() ()
#24 0x0000000000a980ec in c_common_parse_file() ()
#25 0x0000000000f21440 in ?? ()
#26 0x0000000000864568 in toplev::main(int, char**) ()
#27 0x0000000000867bef in main ()
Comment 1 Jakub Jelinek 2018-12-06 17:24:49 UTC
Started with r253265.
Comment 2 Jakub Jelinek 2019-01-31 14:12:42 UTC
Related to e.g. PR89138 - lambdas and VLAs don't play nicely together right now.
Comment 3 Jason Merrill 2019-02-22 02:48:05 UTC
Author: jason
Date: Fri Feb 22 02:47:33 2019
New Revision: 269094

URL: https://gcc.gnu.org/viewcvs?rev=269094&root=gcc&view=rev
Log:
	PR c++/88394 - ICE with VLA init-capture.

We mostly use is_normal_capture_proxy to decide whether or not to use
DECL_CAPTURED_VARIABLE; we could just check whether it's set.  VLA capture
is still mostly broken, but this fixes this ICE.

	* lambda.c (is_normal_capture_proxy): Check DECL_CAPTURED_VARIABLE.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/lambda-init-vla1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/lambda.c
Comment 4 Jason Merrill 2019-02-22 02:48:16 UTC
Fixed on trunk so far.
Comment 5 Jakub Jelinek 2019-02-22 15:26:25 UTC
GCC 8.3 has been released.
Comment 6 GCC Commits 2020-02-26 04:23:28 UTC
The releases/gcc-8 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:bf2fe5d49627ca757123f4425a029bd92c50fc05

commit r8-10068-gbf2fe5d49627ca757123f4425a029bd92c50fc05
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Feb 25 21:29:03 2020 -0500

    PR c++/88394 - ICE with VLA init-capture.
    
    We mostly use is_normal_capture_proxy to decide whether or not to use
    DECL_CAPTURED_VARIABLE; we could just check whether it's set.  VLA capture
    is still mostly broken, but this fixes this ICE.
    
    gcc/cp/ChangeLog
    2020-02-25  Jason Merrill  <jason@redhat.com>
    
    	PR c++/88394 - ICE with VLA init-capture.
    	* lambda.c (is_normal_capture_proxy): Check DECL_CAPTURED_VARIABLE.
Comment 7 Jason Merrill 2020-02-26 17:59:16 UTC
Fixed for 8.4.