[{"id":1760547,"web_url":"http://patchwork.ozlabs.org/comment/1760547/","msgid":"<CADzB+2ntdqjpd81A=Z5seRQ6XJ4Gjd1QXgZv4i2qWZ4Gy2QpSQ@mail.gmail.com>","list_archive_url":null,"date":"2017-08-30T22:36:17","subject":"Re: C++ PATCH for c++/80767,\n\tunnecessary instantiation of generic lambda","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"On Tue, Aug 29, 2017 at 3:12 PM, Jason Merrill <jason@redhat.com> wrote:\n> In this testcase, when we try to call the object of 'overloader' type,\n> we consider the conversion function from the first lambda to void\n> (*)(a) and build up a surrogate call function for it.  We consider how\n> to convert from overloader to that type, which means also looking at\n> the template conversion function from the second lambda, which\n> involves instantiating the operator() to determine the return type,\n> which is ill-formed.\n>\n> But the standard seems to say that we shouldn't bother to consider how\n> to do that conversion unless we actually choose the surrogate call\n> function for that type, so that's what this patch implemenets.\n\nWe also need to adjust joust to handle a null candidate.\ncommit f57bf1708cc3824fd0047ecd883ecb28341bcdb8\nAuthor: Jason Merrill <jason@redhat.com>\nDate:   Wed Aug 30 17:30:02 2017 -0400\n\n            PR c++/82030 - ICE inheriting from multiple lambdas\n    \n            PR c++/80767\n            * call.c (compare_ics): Handle null candidate.\n\ndiff --git a/gcc/cp/call.c b/gcc/cp/call.c\nindex c446057..9e4a5c1 100644\n--- a/gcc/cp/call.c\n+++ b/gcc/cp/call.c\n@@ -9561,7 +9561,9 @@ compare_ics (conversion *ics1, conversion *ics2)\n \treturn 0;\n       else if (t1->kind == ck_user)\n \t{\n-\t  if (t1->cand->fn != t2->cand->fn)\n+\t  tree f1 = t1->cand ? t1->cand->fn : t1->type;\n+\t  tree f2 = t2->cand ? t2->cand->fn : t2->type;\n+\t  if (f1 != f2)\n \t    return 0;\n \t}\n       else\ndiff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv12.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv12.C\nnew file mode 100644\nindex 0000000..16adee6\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv12.C\n@@ -0,0 +1,18 @@\n+// PR c++/80767\n+// { dg-do compile { target c++11 } }\n+\n+template <typename T, typename U = T> struct A { using type = U; };\n+template <typename F, typename... G> struct B : B<F>::type, B<G...>::type {\n+  using type = B;\n+  using B<F>::type::operator();\n+};\n+template <typename F> struct B<F> { using type = F; };\n+struct {\n+  template <typename... F,\n+            typename Overload = typename B<typename A<F>::type...>::type>\n+  Overload operator()(F...){}\n+} a;\n+int main() {\n+  auto f = a([](int) {}, [](float) {});\n+  f({});\n+}","headers":{"Return-Path":"<gcc-patches-return-461194-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461194-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"XaL3kXZc\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjL3J696Kz9s7G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 08:36:59 +1000 (AEST)","(qmail 126789 invoked by alias); 30 Aug 2017 22:36:50 -0000","(qmail 126714 invoked by uid 89); 30 Aug 2017 22:36:50 -0000","from mail-io0-f175.google.com (HELO mail-io0-f175.google.com)\n\t(209.85.223.175) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tWed, 30 Aug 2017 22:36:40 +0000","by mail-io0-f175.google.com with SMTP id d78so10861921ioe.4 for\n\t<gcc-patches@gcc.gnu.org>; Wed, 30 Aug 2017 15:36:39 -0700 (PDT)","by 10.107.181.23 with HTTP; Wed, 30 Aug 2017 15:36:17 -0700 (PDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:date:message-id\n\t:subject:to:content-type; q=dns; s=default; b=vdPhAxdv7uVqt7euoj\n\tco60O/HI0Dlm2CJpNsKs8l4uqC73GVG+8j/ovTKW0Bv0nGLfWvpSpL5tr7Vx1NOD\n\tf7wwjKgj3NlBtPrlHIzb+v/hahXz8QKQ5BlIrXFsgbXzRC7h9lss/NUOmSmJRIGf\n\trfRtn8K7ImiyW1CDm+x+7ZXYs=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:date:message-id\n\t:subject:to:content-type; s=default; bh=00+8omMWNw3grKZNSIbFt2JE\n\tkqQ=; b=XaL3kXZcyqo59l6WP6sFGvKG0u/1FoKi1O6gPIVUxVPaSetk7sgyhMEf\n\txZejrKxNxxcRZPPurcrPEkgqirq98V8ENwy2pBuR8ZnGq+NdhnKB29WUDonBldsH\n\tH34nNDY1GnmmZ50Gg9zzhg5s8bz2hMKgDyXdTspXhWopRfGdpkA=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-25.0 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tRCVD_IN_DNSWL_NONE,\n\tRCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy=","X-HELO":"mail-io0-f175.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to;\n\tbh=0AdlgpNmOtuYv/Jc9G8UWConxN99P/HOhxna06hk+mA=;\n\tb=lvQuXRJUNlUghPVcex3rfjDG/ClsXy5OE5YigURHE6Ar1T2oSTWwpQ+3/OBr3ojVJm\n\t9ExrVBs8V7TDJADUZiYk+jSuiXUHC47fKxNYpxQ/BxiYShJvC4PnsAerO0ys3mqNUIE5\n\tZZOkJdLOZ2pEbpXaQgHShOxS6+pldQ+Pb60iR/YzWiLmbe7gdHVFXkgft3RAjoaPfOde\n\tWRJ06PnPh9QeISTEoac05dFIN35PfIPYsSSrsPQHhev+b//mWX8EO8qSGfHhbGhJ6CH+\n\t2lLf79XeS3D6ghEDuEx3BST+7OyY9rK9DSFudsN63kmxo0iZnqd02Rg5ls2QKE922WXZ\n\tjzSw==","X-Gm-Message-State":"AHYfb5jlQGt4dgEFkdNGaZMF/hTuOAPp6DcjjHlD+iCHQm3K+l/LgAeL\t+c9v3krSrP3URAv9aAL1TsJ6YX2mz5m8r2w=","X-Received":"by 10.36.165.69 with SMTP id w5mr3244322iti.28.1504132598021;\n\tWed, 30 Aug 2017 15:36:38 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<CADzB+2mQUDKPNznb+Ziqw5T+xCQeOudEXAzOOLmjfNktYaAXqQ@mail.gmail.com>","References":"<CADzB+2mQUDKPNznb+Ziqw5T+xCQeOudEXAzOOLmjfNktYaAXqQ@mail.gmail.com>","From":"Jason Merrill <jason@redhat.com>","Date":"Wed, 30 Aug 2017 18:36:17 -0400","Message-ID":"<CADzB+2ntdqjpd81A=Z5seRQ6XJ4Gjd1QXgZv4i2qWZ4Gy2QpSQ@mail.gmail.com>","Subject":"Re: C++ PATCH for c++/80767,\n\tunnecessary instantiation of generic lambda","To":"gcc-patches List <gcc-patches@gcc.gnu.org>","Content-Type":"multipart/mixed; boundary=\"f403045fb75033bde205580029c9\"","X-IsSubscribed":"yes"}}]