[PR c++/87185] ICE in prune-lambdas
authorPádraig Brady <p@draigbrady.com>
Wed, 5 Sep 2018 09:59:08 +0000 (09:59 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 5 Sep 2018 09:59:08 +0000 (09:59 +0000)
https://gcc.gnu.org/ml/gcc-patches/2018-09/msg00249.html
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.

From-SVN: r264118

gcc/cp/ChangeLog
gcc/cp/lambda.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr87185.C [new file with mode: 0644]

index 3fbfe18bd438bdd7404adc926175d62f07ae1663..498b1fa9252b5bb982d80885da0107816412caea 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-05   Pádraig Brady p@draigbrady.com
+
+       PR c++/87185
+       * lambda.c (prune_lambda_captures): Protect against const_vars.get
+       returning NULL.
+
 2018-09-04  Marek Polacek  <polacek@redhat.com>
 
        * cp-tree.h (treat_lvalue_as_rvalue_p): Declare.
index 25a4d6f7eef4c5bbd727e7b2ef86b8a1e038b185..297327f1ab6bc159fa6e683b4d3a2e9cc44f19f1 100644 (file)
@@ -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 a4db4f8c51727797a1715aa3ab022d46a5edcd09..2b22784192917d75ce930e182b4641442133504f 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-05   Pádraig Brady p@draigbrady.com
+
+       PR c++/87185
+       * g++.dg/pr87185.C: New.
+
 2018-09-05  Martin Liska  <mliska@suse.cz>
 
        PR testsuite/87216
diff --git a/gcc/testsuite/g++.dg/pr87185.C b/gcc/testsuite/g++.dg/pr87185.C
new file mode 100644 (file)
index 0000000..46dae0e
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/87185
+// { dg-do compile { target c++11 } }
+
+void f() { const int i=0; [&]() noexcept {i;}; }