Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2231767/?format=api
{ "id": 2231767, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2231767/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260501120115.2535042-1-jwakely@redhat.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/1.1/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null }, "msgid": "<20260501120115.2535042-1-jwakely@redhat.com>", "date": "2026-05-01T11:51:32", "name": "[v2] libstdc++: Make std::unique_ptr<void>::operator* SFINAE-friendly", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ce546c9bb687d735af98b1ce54617d5bb56ad63c", "submitter": { "id": 48004, "url": "http://patchwork.ozlabs.org/api/1.1/people/48004/?format=api", "name": "Jonathan Wakely", "email": "jwakely@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260501120115.2535042-1-jwakely@redhat.com/mbox/", "series": [ { "id": 502448, "url": "http://patchwork.ozlabs.org/api/1.1/series/502448/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=502448", "date": "2026-05-01T11:51:32", "name": "[v2] libstdc++: Make std::unique_ptr<void>::operator* SFINAE-friendly", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/502448/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2231767/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2231767/checks/", "tags": {}, "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=VNVvPqmI;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=VNVvPqmI", "sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com", "sourceware.org; spf=pass smtp.mailfrom=redhat.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g6V5F1Y2Wz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 22:01:51 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 02454436F3D7\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 1 May 2026 12:01:49 +0000 (GMT)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 9EF054371D45\n for <gcc-patches@gcc.gnu.org>; Fri, 1 May 2026 12:01:20 +0000 (GMT)", "from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-676-LDvUacbNMcGO4_0v2BUQoA-1; Fri,\n 01 May 2026 08:01:19 -0400", "from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id D73A31800350; Fri, 1 May 2026 12:01:17 +0000 (UTC)", "from zen.kayari.org (unknown [10.44.50.237])\n by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id B0B2D300019F; Fri, 1 May 2026 12:01:16 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 02454436F3D7", "OpenDKIM Filter v2.11.0 sourceware.org 9EF054371D45" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 9EF054371D45", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 9EF054371D45", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777636880; cv=none;\n b=rqwnGUcGhH0kyG+xaVQc6pgxLf/XwwMdYwNi8HV/cgJqS8oAWoCE5lfi7WLi5YKWzmQj6q0KL2exSURbTiAzDiYGqXxxLs04XIDiFd58fpSunA2F+auVgDtBf/GkgIU9E6EDMQHgKcSI0qarHF1UPl2qmaiM9Z/JxdM3i0bx6rg=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777636880; c=relaxed/simple;\n bh=aPtuVWC+PEOk7Nd3+cgNs99h1br/aXCAF6V62gkHxSU=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=Nm/XXE3ZMG4oRY+lXgKlWybKDymvImSe/86875LTbNk1/yrezpxMNxbf61SQucVY5we4AboLrW12ZlpdKc1D8eCaYFnsntVKzKr0ljrb1im+LeTyoiT0A9lChcv1qDUNDKK7s1aWz1sr5x7uGQzvPhxvZeWNnrlDDpJwT7f0zlw=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1777636880;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=/5ftKP0j/i46p7OkG0aHvsN+Y8PkUPUi1KSNDgaLFIw=;\n b=VNVvPqmIikxTTjkaPJzeTOXpCruLhivJUYpYCLrujbk0MnL7d0maiZIPEWLzgDJ9U9VZZG\n /iEcuBUr2fA7JUs47aJx95ztxqaqE3hzXTTZGrqpPzV6lWM61z1pmGYzQnhq6plLGu3IAA\n tfvXIiiX2r4xcTExYsKk60G2MhXPVwo=", "X-MC-Unique": "LDvUacbNMcGO4_0v2BUQoA-1", "X-Mimecast-MFC-AGG-ID": "LDvUacbNMcGO4_0v2BUQoA_1777636878", "From": "Jonathan Wakely <jwakely@redhat.com>", "To": "gcc-patches@gcc.gnu.org,\n\tlibstdc++@gcc.gnu.org", "Subject": "[PATCH v2] libstdc++: Make std::unique_ptr<void>::operator*\n SFINAE-friendly", "Date": "Fri, 1 May 2026 12:51:32 +0100", "Message-ID": "<20260501120115.2535042-1-jwakely@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.4", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "67eDvmFdi2FhnZ3QC6vLfC3j7eNM4r3UuxoNYmjTYvE_1777636878", "X-Mimecast-Originator": "redhat.com", "Content-Type": "text/plain", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "This implements LWG 4324, \"unique_ptr<void>::operator* is not\nSFINAE-friendly\", approved in Croydon, 2026.\n\nThe noexcept-specifier added to C++23 by LWG 2762 is ill-formed if the\npointer type cannot be dereferenced, which means that code which was\nchecking whether the function exists (e.g. in a SFINAE context) no\nlonger works. Such code was always questionable, because the function\nbody was ill-formed if the pointer isn't dereferenceable, so the SFINAE\ncheck was probably giving the wrong answer, but it was possible to ask\nthe question. Since LWG 2762 just asking the question can produce an\nerror outside the immediate context, so operator* is no longer\nSFINAE-friendly.\n\nLWG 4324 adds a constraint to the function, so that it doesn't\nparticipate in overload resolution if it would be ill-formed. That's\neasy to implement for C++20 because we can just add a requires-clause.\n\nFor C++11/14/17 we can't constrain it easily, so just adjust the\nnoexcept-specifier so that it's not ill-formed. This still means you get\nthe wrong answer (i.e. it looks like unique_ptr<void>::operator* is\ncallable) but there's no error outside the immediate context. This\nrestores the original semantics before the LWG 2762 change, for better\nor worse.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/unique_ptr.h (unique_ptr::_Nothrow_deref): New\n\thelper for pre-C++20.\n\t(unique_ptr::operator*): Either constrain or use _Nothrow_deref.\n\t* testsuite/20_util/unique_ptr/lwg4324.cc: New test.\n---\n\nTested x86_64-linux.\n\nv2: Combined _Can_deref and _S_nothrow_deref() into _Nothrow_deref based\non suggestion from Tomasz. Clarified in commit msg that for pre-C++20\nthis restores the pre-LWG2762 semantics, which is that operator* always\nexists, even if calling it would be ill-formed.\n\n libstdc++-v3/include/bits/unique_ptr.h | 21 +++++++++++++++++-\n .../testsuite/20_util/unique_ptr/lwg4324.cc | 22 +++++++++++++++++++\n 2 files changed, 42 insertions(+), 1 deletion(-)\n create mode 100644 libstdc++-v3/testsuite/20_util/unique_ptr/lwg4324.cc", "diff": "diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h\nindex 5b7c8938ff74..f4b2e33d13de 100644\n--- a/libstdc++-v3/include/bits/unique_ptr.h\n+++ b/libstdc++-v3/include/bits/unique_ptr.h\n@@ -289,6 +289,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \t __not_<is_array<_Up>>\n >;\n \n+#if ! __cpp_concepts\n+ template<typename _Ptr, typename = void>\n+\tstruct _Nothrow_deref\n+\t: false_type { };\n+\n+ template<typename _Ptr>\n+\tstruct _Nothrow_deref<_Ptr, __void_t<decltype(*std::declval<_Ptr>())>>\n+\t: __bool_constant<noexcept(*std::declval<_Ptr>())> { };\n+#endif\n+\n public:\n // Constructors.\n \n@@ -442,7 +452,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n /// Dereference the stored pointer.\n _GLIBCXX23_CONSTEXPR\n typename add_lvalue_reference<element_type>::type\n- operator*() const noexcept(noexcept(*std::declval<pointer>()))\n+ operator*() const\n+ // _GLIBCXX_RESOLVE_LIB_DEFECTS\n+ // 2762. unique_ptr operator*() should be noexcept\n+ // 4324. unique_ptr<void>::operator* is not SFINAE-friendly\n+#if __cpp_concepts\n+ noexcept(noexcept(*std::declval<pointer>()))\n+ requires requires { *std::declval<pointer>(); }\n+#else\n+ noexcept(_Nothrow_deref<pointer>::value)\n+#endif\n {\n #if _GLIBCXX_USE_BUILTIN_TRAIT(__reference_converts_from_temporary)\n \t// _GLIBCXX_RESOLVE_LIB_DEFECTS\ndiff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4324.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4324.cc\nnew file mode 100644\nindex 000000000000..13ebfb929fca\n--- /dev/null\n+++ b/libstdc++-v3/testsuite/20_util/unique_ptr/lwg4324.cc\n@@ -0,0 +1,22 @@\n+// { dg-do compile { target c++11 } }\n+\n+// LWG 4324. unique_ptr<void>::operator* is not SFINAE-friendly\n+\n+#include <memory>\n+\n+template<class T, bool = true>\n+struct nothrow_dereference\n+: std::false_type { };\n+\n+template<class T>\n+struct nothrow_dereference<T, noexcept(*std::declval<T>())>\n+: std::true_type { };\n+\n+static_assert( nothrow_dereference<std::unique_ptr<int>>::value, \"\");\n+static_assert( ! nothrow_dereference<std::unique_ptr<void>>::value, \"\");\n+\n+#if __cplusplus >= 202002L // C++20\n+template<class T> concept dereferenceable = requires(T& t) { *t; };\n+static_assert( dereferenceable<std::unique_ptr<int>>);\n+static_assert(!dereferenceable<std::unique_ptr<void>>);\n+#endif\n", "prefixes": [ "v2" ] }