[gcc(refs/vendors/redhat/heads/gcc-8-branch)] PR c++/88394 - ICE with VLA init-capture.
Jakub Jelinek
jakub@gcc.gnu.org
Thu Sep 17 16:46:28 GMT 2020
https://gcc.gnu.org/g:02b23398b02d74f30ca2cd55c164cc43cee50309
commit 02b23398b02d74f30ca2cd55c164cc43cee50309
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.
Diff:
---
gcc/cp/ChangeLog | 5 +++++
gcc/cp/lambda.c | 16 ++--------------
gcc/testsuite/g++.dg/cpp1y/lambda-init-vla1.C | 12 ++++++++++++
3 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a6b54d569de..ba809fda880 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
2019-02-05 Alexandre Oliva <aoliva@redhat.com>
PR c++/87770
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 744880bd532..29a894fd86a 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -278,20 +278,8 @@ is_normal_capture_proxy (tree decl)
/* It's not a capture proxy. */
return false;
- if (variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
- /* VLA capture. */
- return true;
-
- /* It is a capture proxy, is it a normal capture? */
- tree val = DECL_VALUE_EXPR (decl);
- if (val == error_mark_node)
- return true;
-
- if (TREE_CODE (val) == ADDR_EXPR)
- val = TREE_OPERAND (val, 0);
- gcc_assert (TREE_CODE (val) == COMPONENT_REF);
- val = TREE_OPERAND (val, 1);
- return DECL_NORMAL_CAPTURE_P (val);
+ return (DECL_LANG_SPECIFIC (decl)
+ && DECL_CAPTURED_VARIABLE (decl));
}
/* Returns true iff DECL is a capture proxy for a normal capture
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init-vla1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init-vla1.C
new file mode 100644
index 00000000000..1fef7b4a7f9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init-vla1.C
@@ -0,0 +1,12 @@
+// PR c++/88394
+// { dg-do compile { target c++14 } }
+// { dg-options "" }
+
+void crash_me(unsigned short sz)
+{
+ if (sz == 0) return;
+
+ short iov[sz];
+ auto fce = [&iv = iov](short value) { iv[0] = 0; };
+ fce(1);
+}
More information about the Gcc-cvs
mailing list