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

Reply via email to