On 04/09/2015 11:31 PM, Adam Butcher wrote:
+               /* For generic lambdas, resolve default captured 'this' now.  */
+               if (processing_template_decl
+                   && is_dummy_object (instance)
+                   && current_class_type
+                   && CLASSTYPE_LAMBDA_EXPR (current_class_type))
+                 if (tree callop = lambda_function (current_class_type))
+                   if (DECL_TEMPLATE_INFO (callop)
+                       && (DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (callop))
+                           == callop)
+                       && TREE_TYPE (instance) != current_class_type
+                       && DERIVED_FROM_P (TREE_TYPE (instance),
+                                          current_nonlambda_class_type ()))
+                     TREE_OPERAND (postfix_expression, 0)
+                       = instance
+                       = maybe_resolve_dummy (instance, true);

This isn't quite right. We don't want to capture 'this' any time we see a member function call, as overload resolution might choose a static member function that doesn't need 'this'. The special handling we want is for the case where the call depends on a generic lambda parameter, in which case we capture 'this' because the call "names [this] in a potentially-evaluated expression (3.2) where the enclosing full-expression depends on a generic lambda parameter declared within the reaching scope of the lambda-expression."

Jason

Reply via email to