From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 8722C3858D37; Wed, 5 Oct 2022 12:46:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8722C3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664973964; bh=AoGo7NONBpkdBf8g4Ig7+kuurgpzmf8nHjVOrnJzkjA=; h=From:To:Subject:Date:From; b=ituTpquiw5hvN3tkVGQfjEj+akHPnKldU2n8VUpDzbi0K0RkGC4V0YuQmWaHJ6Cd2 cOet9otr3reJP9yg4V1DBJ3uV25m+LmzfQIW68OKfYqZ7OS5RWW/HbAVkw3DYciLXO 4Cq6pRpf5u5bx2oy8vgZOeyhAfuSmBa5eL4fFFTM= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-3087] libstdc++: Guard use of new built-in with __has_builtin X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 4c451631f722c9939260a5c2fc209802a47e525f X-Git-Newrev: dc70f3f81bb980b69a1910c2e6d3774ddd716846 Message-Id: <20221005124604.8722C3858D37@sourceware.org> Date: Wed, 5 Oct 2022 12:46:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:dc70f3f81bb980b69a1910c2e6d3774ddd716846 commit r13-3087-gdc70f3f81bb980b69a1910c2e6d3774ddd716846 Author: Jonathan Wakely Date: Thu Sep 29 11:30:05 2022 +0100 libstdc++: Guard use of new built-in with __has_builtin 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. Diff: --- 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)...);