{"id":816356,"url":"http://patchwork.ozlabs.org/api/patches/816356/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20170920163424.GA30540@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","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,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170920163424.GA30540@redhat.com>","list_archive_url":null,"date":"2017-09-20T16:34:24","name":"Deprecate nested types in std::hash","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ebba5fbae1788ee7ae57d58650b4314daafa44c0","submitter":{"id":48004,"url":"http://patchwork.ozlabs.org/api/people/48004/?format=json","name":"Jonathan Wakely","email":"jwakely@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20170920163424.GA30540@redhat.com/mbox/","series":[{"id":4173,"url":"http://patchwork.ozlabs.org/api/series/4173/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=4173","date":"2017-09-20T16:34:24","name":"Deprecate nested types in std::hash","version":1,"mbox":"http://patchwork.ozlabs.org/series/4173/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816356/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816356/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-462618-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-462618-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=\"wASHa5kI\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jwakely@redhat.com"],"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 3xy51W1WYrz9t2Q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 02:34:38 +1000 (AEST)","(qmail 17863 invoked by alias); 20 Sep 2017 16:34:29 -0000","(qmail 17838 invoked by uid 89); 20 Sep 2017 16:34:28 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tWed, 20 Sep 2017 16:34:27 +0000","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.13])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id C84FC4E34A;\n\tWed, 20 Sep 2017 16:34:25 +0000 (UTC)","from localhost (unknown [10.33.36.48])\tby smtp.corp.redhat.com\n\t(Postfix) with ESMTP id 66B9C6060A;\n\tWed, 20 Sep 2017 16:34:25 +0000 (UTC)"],"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:date\n\t:from:to:subject:message-id:mime-version:content-type; q=dns; s=\n\tdefault; b=fWDV+PyYwjvD1ZuEAdKMn6sRl2t08591TyMmHYGsrKdb1RzPAIW1f\n\tWz+x1BQ26Pqm0qIk0eUDAXk8HmFlFOa2kJ6bw8Cf7zSdVr1orcEZCRv7f9mqMO3+\n\toEfHRUDYhii3BNNAywFQ82E3lW5o31o5RNR+qVo9g/1D+/UpbaZ8Dw=","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:date\n\t:from:to:subject:message-id:mime-version:content-type; s=\n\tdefault; bh=uMSK3k1sYIqIkXYi/9YYM6/9mwE=; b=wASHa5kIxEfXQq/PjBUv\n\tyNLLUpqcKBejXHI2pheUAfkngsbq86Q8sD4AxKAjdstb/RTCvCpVuvYgFpbYBd2b\n\trJyzZPYvZGAy35NzHX94r7qUrop1QGJ/lW93YYuVvOODE4969WKDJsyYLf0iseN0\n\t0RKB1daqRyBJVjPKENlfML4=","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=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=containers","X-Spam-User":"qpsmtpd, 2 recipients","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com C84FC4E34A","Date":"Wed, 20 Sep 2017 17:34:24 +0100","From":"Jonathan Wakely <jwakely@redhat.com>","To":"libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org","Subject":"[PATCH] Deprecate nested types in std::hash","Message-ID":"<20170920163424.GA30540@redhat.com>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"BOKacYhQ+x31HxR3\"","Content-Disposition":"inline","X-Clacks-Overhead":"GNU Terry Pratchett","User-Agent":"Mutt/1.9.0 (2017-09-02)"},"content":"C++17 deprecates the argument_type and result_type members of\nstd::hash specializations. This adds the deprecated attribute to them.\n\nC++17 also deprecates those nested typedefs (and weak result types) in\nowner_less, plus, minus, function, reference_wrapper, bind,\n{multi,}map::value_compare etc. but we can do that later. I wanted to\nmake this change now for the new hash<variant<T...>> and\nhash<optional<T>> specializations that are new in C++17.\n\nI'm also adding partial specializations for __is_fast_hash for those\nnew hash specializations, so that unordered containers of\noptional<string> or variant<..., string, ...> will cache the hash\ncode.\n\n\t* include/bits/c++config (_GLIBCXX17_DEPRECATED): Define.\n\t* include/bits/functional_hash.h (__hash_base::result_type)\n\t(__hash_base::argument_type): Add _GLIBCXX17_DEPRECATED.\n\t* include/std/optional (hash<optional<T>>::result_type)\n\t(hash<optional<T>>::argument_type): Add deprecated attribute.\n\t(__is_fast_hash<hash<optional<T>>>): Add partial specialization.\n\t* include/std/variant (hash<variant<Types...>>::result_type)\n\t(hash<variant<Types...>>::argument_type): Add deprecated attribute.\n\t(__is_fast_hash<hash<variant<Types...>>>): Add partial specialization.\n\nTested powerpc64le, committed to trunk.\n\nI don't think this is suitable for backporting to gcc-7-branch. The\n__is_fast_hash parts would cause incompatibilities between 7.2 and 7.3\nfor unordered containers.\ncommit 5ecfc92eb86d8e6a90e1168fe6b4b2ab8cd0f8e4\nAuthor: Jonathan Wakely <jwakely@redhat.com>\nDate:   Wed Sep 20 14:33:42 2017 +0100\n\n    Deprecate nested types in std::hash\n    \n            * include/bits/c++config (_GLIBCXX17_DEPRECATED): Define.\n            * include/bits/functional_hash.h (__hash_base::result_type)\n            (__hash_base::argument_type): Add _GLIBCXX17_DEPRECATED.\n            * include/std/optional (hash<optional<T>>::result_type)\n            (hash<optional<T>>::argument_type): Add deprecated attribute.\n            (__is_fast_hash<hash<optional<T>>>): Add partial specialization.\n            * include/std/variant (hash<variant<Types...>>::result_type)\n            (hash<variant<Types...>>::argument_type): Add deprecated attribute.\n            (__is_fast_hash<hash<variant<Types...>>>): Add partial specialization.","diff":"diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config\nindex d5d1d24ee1a..21e3fbb2741 100644\n--- a/libstdc++-v3/include/bits/c++config\n+++ b/libstdc++-v3/include/bits/c++config\n@@ -77,6 +77,7 @@\n // Macros for deprecated attributes.\n //   _GLIBCXX_USE_DEPRECATED\n //   _GLIBCXX_DEPRECATED\n+//   _GLIBCXX17_DEPRECATED\n #ifndef _GLIBCXX_USE_DEPRECATED\n # define _GLIBCXX_USE_DEPRECATED 1\n #endif\n@@ -87,6 +88,12 @@\n # define _GLIBCXX_DEPRECATED\n #endif\n \n+#if defined(__DEPRECATED) && (__cplusplus >= 201703L)\n+# define _GLIBCXX17_DEPRECATED [[__deprecated__]]\n+#else\n+# define _GLIBCXX17_DEPRECATED\n+#endif\n+\n // Macros for ABI tag attributes.\n #ifndef _GLIBCXX_ABI_TAG_CXX11\n # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ (\"cxx11\")))\ndiff --git a/libstdc++-v3/include/bits/functional_hash.h b/libstdc++-v3/include/bits/functional_hash.h\nindex 38be1724d3f..c0936843ac0 100644\n--- a/libstdc++-v3/include/bits/functional_hash.h\n+++ b/libstdc++-v3/include/bits/functional_hash.h\n@@ -49,8 +49,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n   template<typename _Result, typename _Arg>\n     struct __hash_base\n     {\n-      typedef _Result     result_type;\n-      typedef _Arg      argument_type;\n+      typedef _Result     result_type _GLIBCXX17_DEPRECATED;\n+      typedef _Arg      argument_type _GLIBCXX17_DEPRECATED;\n     };\n \n   /// Primary class template hash.\ndiff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional\nindex 2df9b5443ef..e017eedbde7 100644\n--- a/libstdc++-v3/include/std/optional\n+++ b/libstdc++-v3/include/std/optional\n@@ -1028,10 +1028,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n     : private __poison_hash<remove_const_t<_Tp>>,\n       public __optional_hash_call_base<_Tp>\n     {\n-      using result_type = size_t;\n-      using argument_type = optional<_Tp>;\n+      using result_type [[__deprecated__]] = size_t;\n+      using argument_type [[__deprecated__]] = optional<_Tp>;\n     };\n \n+  template<typename _Tp>\n+    struct __is_fast_hash<hash<optional<_Tp>>> : __is_fast_hash<hash<_Tp>>\n+    { };\n+\n   /// @}\n \n   template <typename _Tp> optional(_Tp) -> optional<_Tp>;\ndiff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant\nindex ee2571b7857..8f574f63924 100644\n--- a/libstdc++-v3/include/std/variant\n+++ b/libstdc++-v3/include/std/variant\n@@ -1420,15 +1420,15 @@ namespace __variant\n \tvariant<_Types...>, std::index_sequence_for<_Types...>>,\n       public __variant_hash_call_base<_Types...>\n     {\n-      using result_type = size_t;\n-      using argument_type = variant<_Types...>;\n+      using result_type [[__deprecated__]] = size_t;\n+      using argument_type [[__deprecated__]] = variant<_Types...>;\n     };\n \n   template<>\n     struct hash<monostate>\n     {\n-      using result_type = size_t;\n-      using argument_type = monostate;\n+      using result_type [[__deprecated__]] = size_t;\n+      using argument_type [[__deprecated__]] = monostate;\n \n       size_t\n       operator()(const monostate& __t) const noexcept\n@@ -1438,6 +1438,11 @@ namespace __variant\n       }\n     };\n \n+  template<typename... _Types>\n+    struct __is_fast_hash<hash<variant<_Types...>>>\n+    : bool_constant<(__is_fast_hash<_Types>::value && ...)>\n+    { };\n+\n _GLIBCXX_END_NAMESPACE_VERSION\n } // namespace std\n \n","prefixes":[]}