This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PR c++/87185] ICE in prune-lambdas
- From: Nathan Sidwell <nathan at acm dot org>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Pádraig Brady <P at draigBrady dot com>
- Date: Wed, 5 Sep 2018 10:50:59 +0100
- Subject: [PR c++/87185] ICE in prune-lambdas
I'm applying this patch of Pádraig's. It's a sufficiently obvious
NULL-ptr-dereference fix.
tested on x86_64-linux.
nathan
--
Nathan Sidwell
2018-09-05 Pádraig Brady p@draigbrady.com
cp/
PR c++/87185
* lambda.c (prune_lambda_captures): Protect against const_vars.get
returning NULL.
testsuite/
PR c++/87185
* g++.dg/pr87185.C: New.
Index: cp/lambda.c
===================================================================
--- cp/lambda.c (revision 264112)
+++ cp/lambda.c (working copy)
@@ -1519,8 +1519,8 @@ prune_lambda_captures (tree body)
tree cap = *capp;
if (tree var = var_to_maybe_prune (cap))
{
- tree *use = *const_vars.get (var);
- if (TREE_CODE (*use) == DECL_EXPR)
+ tree **use = const_vars.get (var);
+ if (use && TREE_CODE (**use) == DECL_EXPR)
{
/* All uses of this capture were folded away, leaving only the
proxy declaration. */
@@ -1535,7 +1535,7 @@ prune_lambda_captures (tree body)
*fieldp = DECL_CHAIN (*fieldp);
/* And remove the capture proxy declaration. */
- *use = void_node;
+ **use = void_node;
continue;
}
}
Index: testsuite/g++.dg/pr87185.C
===================================================================
--- testsuite/g++.dg/pr87185.C (nonexistent)
+++ testsuite/g++.dg/pr87185.C (working copy)
@@ -0,0 +1,4 @@
+// PR c++/87185
+// { dg-do compile { target c++11 } }
+
+void f() { const int i=0; [&]() noexcept {i;}; }