From patchwork Wed Oct 5 12:46:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp580010wrs; Wed, 5 Oct 2022 05:47:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4kLdI0Kgm5XeQWc1yZ4R7zPv1jTvTSOQ+FS6qy06rm01vI+ZjkqycvQq3+b7Ffp3AigoY2 X-Received: by 2002:a17:906:f43:b0:78b:fd32:b32b with SMTP id h3-20020a1709060f4300b0078bfd32b32bmr10866875ejj.461.1664974053747; Wed, 05 Oct 2022 05:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664974053; cv=none; d=google.com; s=arc-20160816; b=CjxG+kMvfzfKgxK3pPCQLQSWPmNdODXecWftzC4V2IHLSYM6HbPN2acJkxiAHi9UkK EIV3ojwOm7X8kjs89psckjqEBZMnUSlXUeb/IAoPGuBHWAGstk8qzAtxudJ9BzygK2/b lIfOfOvfFPgnjWb3bTolTxSvvwlbg6kmK87gka1SBZo0a4QzPsttOBBdqmWRKsjRjppM dN9U/IhhrwpZIca5ZNvnchTUUFNtc7lkKhLwmwngs/ekd53VPjhO6kvCaVBvoMnqRDQb FsrVKS1I0Z7lNzW7nCoThRawYF5nTWNdKYvEWMHTc0z5VSMiJ2E9uYE1DMFutNIavz1B b7dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=FDkJu76Ya8BQSBloD1lBDvOPu328081qiw11Q4yk36Y=; b=Zxq4ql8sTuAx+DUL0EjY9fihmRn6gOSH6ttfno5mqG0O9/InxBck7+v4iTIjqmhaTf LQ0NE+JEe8PyKdbFMYxjMiMdw4CyPZCM1nX1+CdKAyzr2CPqyECrqA8VMFMNi/5gv9C2 xSjahB8ng0UyQ4qeiDfhSjY792yJOPREMk/7sisdOHHRlhK42X8veg4uMiq32XtEUrve zU28KbZuAPc1+nD5Khx5aCG/IITzR2wF+Ihd81DPGQDAZfjvO8NdXWjKFq6rJysROuXL A5OH19uoJdVYCE7eNKaj5Gxdt7WzqSIRSktDjPFmJYSLcQdA8JfUkFrCaiVo4N4i8ocB nbQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gL0vM5yY; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qk20-20020a1709077f9400b00783f9fa3a5asi15318247ejc.846.2022.10.05.05.47.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 05:47:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gL0vM5yY; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D7196385703E for ; Wed, 5 Oct 2022 12:47:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7196385703E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664974041; bh=FDkJu76Ya8BQSBloD1lBDvOPu328081qiw11Q4yk36Y=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gL0vM5yYhspGRPDXA0d6O4lIMQV2RxGALGVr1EOMpSYt5nOTYPd9sV1rl1XlG+1f4 B2MslmvpIOMVJV8C3+nUnaNOxp5u/GiMibNcgkdIgzfuwMXOmOskP9DdrWGEuQG0Nz voCLtYSdi+2FAn7tiaatt3Eh+0Wq5ZQHX+73DLKE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 27EAB385782F for ; Wed, 5 Oct 2022 12:46:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 27EAB385782F Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-660-tzK5ZUZ0MTqK79QiLK8Ahw-1; Wed, 05 Oct 2022 08:46:37 -0400 X-MC-Unique: tzK5ZUZ0MTqK79QiLK8Ahw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 187F883394D; Wed, 5 Oct 2022 12:46:32 +0000 (UTC) Received: from localhost (unknown [10.33.36.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9174F2166B26; Wed, 5 Oct 2022 12:46:29 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Guard use of new built-in with __has_builtin Date: Wed, 5 Oct 2022 13:46:28 +0100 Message-Id: <20221005124628.701564-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745851833147897026?= X-GMAIL-MSGID: =?utf-8?q?1745851833147897026?= Tested x86_64-linux, pushed to trunk. -- >8 -- Another case where I forgot that non-GCC compilers don't have this built-in yet. libstdc++-v3/ChangeLog: * include/bits/invoke.h (__invoke_r): Check __has_builtin(__reference_converts_from_temporary) before using built-in. --- libstdc++-v3/include/bits/invoke.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libstdc++-v3/include/bits/invoke.h b/libstdc++-v3/include/bits/invoke.h index 8724a764f73..8fa8cf876d8 100644 --- a/libstdc++-v3/include/bits/invoke.h +++ b/libstdc++-v3/include/bits/invoke.h @@ -130,8 +130,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { using __result = __invoke_result<_Callable, _Args...>; using __type = typename __result::type; +#if __has_builtin(__reference_converts_from_temporary) static_assert(!__reference_converts_from_temporary(_Res, __type), "INVOKE must not create a dangling reference"); +#endif using __tag = typename __result::__invoke_type; return std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn), std::forward<_Args>(__args)...);