From: Jason Merrill Date: Fri, 22 Jul 2016 03:57:43 +0000 (-0400) Subject: PR c++/69223 - ICE with deduced template return type. X-Git-Tag: releases/gcc-4.9.4~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cc946ffcb6dc4bd7444b9ef2e56c2dcef5c3b43;p=thirdparty%2Fgcc.git PR c++/69223 - ICE with deduced template return type. * semantics.c (apply_deduced_return_type): Call complete_type_or_else before building the new RESULT_DECL. From-SVN: r238631 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 553c2ba8fc7a..db5eb75223b9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2016-07-21 Jason Merrill + PR c++/69223 + * semantics.c (apply_deduced_return_type): Call + complete_type_or_else before building the new RESULT_DECL. + PR c++/71913 * call.c (unsafe_copy_elision_p): It's OK to elide when initializing an unknown object. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index bc8fec1103ba..7699765fe586 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -10664,6 +10664,10 @@ apply_deduced_return_type (tree fco, tree return_type) if (TREE_TYPE (result) == return_type) return; + if (!processing_template_decl && !VOID_TYPE_P (return_type) + && !complete_type_or_else (return_type, NULL_TREE)) + return; + /* We already have a DECL_RESULT from start_preparsed_function. Now we need to redo the work it and allocate_struct_function did to reflect the new type. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce3.C new file mode 100644 index 000000000000..68ac29c9eac2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce3.C @@ -0,0 +1,15 @@ +// PR c++/69223 +// { dg-do compile { target c++11 } } + +template struct A +{ + T x[20]; +}; + +int main() +{ + auto l = [](const A& i){ return i; }; + A a; + + l(a); +}