* C++ PATCH for c++/65339 (ICE with lambda)
@ 2015-03-09 19:51 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2015-03-09 19:51 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 388 bytes --]
In this testcase we were crashing while trying to build up a copy
constructor call within the thunk for the function pointer conversion
operator, because we try to resolve 'this' and there is no 'this' in a
static member function. Fixed by avoiding that resolution when we're
calling a constructor, which never implicitly uses 'this'.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 65339.patch --]
[-- Type: text/x-patch, Size: 1584 bytes --]
commit 63ca18a58a5fab2281872955d71bbeb44956a835
Author: Jason Merrill <jason@redhat.com>
Date: Fri Mar 6 14:45:55 2015 -0500
PR c++/65339
* call.c: Don't call maybe_resolve_dummy when calling a constructor.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 2b15185..fdd8436 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<tree, va_gc> **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 0000000..d7955fd
--- /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 <typename Func> 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();
+ });
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-03-09 19:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-09 19:51 C++ PATCH for c++/65339 (ICE with lambda) Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).