From: Jason Merrill Date: Mon, 9 Mar 2015 19:59:54 +0000 (-0400) Subject: re PR c++/65339 (C++ ICE with lambda and no capture list) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a2f259ef04b104e6ee9770b2d4c11c93195654ad;p=gcc.git re PR c++/65339 (C++ ICE with lambda and no capture list) PR c++/65339 * call.c: Don't call maybe_resolve_dummy when calling a constructor. From-SVN: r221285 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cd2d0765998..67aa184bcb1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-03-09 Jason Merrill + + PR c++/65339 + * call.c: Don't call maybe_resolve_dummy when calling a constructor. + 2015-03-09 Jakub Jelinek PR c/65120 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 2b15185a895..fdd8436d53e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8020,7 +8020,11 @@ build_new_method_call_1 (tree instance, tree fns, vec **args, that would be captured if the call turns out to be to a non-static member function. Do not actually capture it at this point. */ - first_mem_arg = maybe_resolve_dummy (instance, false); + if (DECL_CONSTRUCTOR_P (fn)) + /* Constructors don't use the enclosing 'this'. */ + first_mem_arg = instance; + else + first_mem_arg = maybe_resolve_dummy (instance, false); /* Get the high-water mark for the CONVERSION_OBSTACK. */ p = conversion_obstack_alloc (0); diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv9.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv9.C new file mode 100644 index 00000000000..d7955fd40c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv9.C @@ -0,0 +1,27 @@ +// PR c++/65339 +// { dg-do compile { target c++11 } } + +class FuncWrapper { +public: + template void callfunc(Func f) + { + f(); + } +}; + +class Object { + int field; +public: + void Method(); + Object() { field = 555; } + Object(const Object&) { __builtin_abort(); } +}; + +void Object::Method () +{ + FuncWrapper wrap; + wrap.callfunc(*[]() + { + return Object(); + }); +}