diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2014-05-22 22:28:24 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2014-05-22 22:28:24 +0000 |
commit | 0c018b6fad1152159e90d0664f808503083eaa2f (patch) | |
tree | 482d94f82159646fb44fea3724778df67a2b8f71 /gcc/cp/lambda.c | |
parent | aa87aced5ba964ce66bb2b6ea135dae8d5879e58 (diff) | |
download | gcc-0c018b6fad1152159e90d0664f808503083eaa2f.zip gcc-0c018b6fad1152159e90d0664f808503083eaa2f.tar.gz gcc-0c018b6fad1152159e90d0664f808503083eaa2f.tar.bz2 |
re PR c++/61088 (segfault with array of lambdas initialized with initializer list that contains a lambda that captures the array)
/cp
2014-05-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/61088
* lambda.c (add_capture): Enforce that capture by value requires
complete type.
* typeck2.c (cxx_incomplete_type_inform): Early return if
TYPE_MAIN_DECL is null.
/testsuite
2014-05-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/61088
* g++.dg/cpp0x/lambda/lambda-ice13.C: New.
* g++.dg/cpp0x/lambda/lambda-ice7.C: Adjust.
From-SVN: r210829
Diffstat (limited to 'gcc/cp/lambda.c')
-rw-r--r-- | gcc/cp/lambda.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index bb6014b..e72682c 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -453,6 +453,9 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p, initializer = build_x_compound_expr_from_list (initializer, ELK_INIT, tf_warning_or_error); type = TREE_TYPE (initializer); + if (type == error_mark_node) + return error_mark_node; + if (array_of_runtime_bound_p (type)) { vla = true; @@ -489,8 +492,16 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p, error ("cannot capture %qE by reference", initializer); } else - /* Capture by copy requires a complete type. */ - type = complete_type (type); + { + /* Capture by copy requires a complete type. */ + type = complete_type (type); + if (!dependent_type_p (type) && !COMPLETE_TYPE_P (type)) + { + error ("capture by copy of incomplete type %qT", type); + cxx_incomplete_type_inform (type); + return error_mark_node; + } + } } /* Add __ to the beginning of the field name so that user code |