This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Jiří Paleček] [PATCH][C+ +] Fix constant reference in a lambda ( PR c++/53488)


Thanks for the patch!

The idea of the fix is to postpone the decision whether or not to capture later to the template instantiation.

That makes sense. We might as well postpone all default captures to instantiation time, since we need to postpone some of them.


+        /* This is a hack:
+
+           We absolutely need the capture list to be nonempty if the
+           template had it nonempty, otherwise, we will have the
+           conversion-to-function-pointer operator erroneously
+           added. We use a dummy list with a single element that we
+           can get rid of easily later
+        */
+	LAMBDA_EXPR_CAPTURE_LIST (r)
+          = LAMBDA_EXPR_CAPTURE_LIST (t) != NULL_TREE ? tree_cons(NULL_TREE, NULL_TREE, NULL_TREE) : NULL_TREE;

I think rather than do this, we should set LAMBDA_EXPR_CAPTURE_LIST in instantiate_class_template_1.


Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]