From patchwork Mon Feb 11 00:19:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 219529 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id F00342C0099 for ; Mon, 11 Feb 2013 11:19:57 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1361146798; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=grpPreL LXbWcX3duiZ04fzvxxf8=; b=FtiVH6Q/1syI55heXV+cP2SaP0nLt0/33AgV+CS /wKqoU/wuy0eSVZ8KNCXasReo2AiqVMEGyJ7O3zDuW+H3qSbFuBlten5KzI+VD4k yCKXP/7wZOBBZkm1o71E6cjKoOO0EINeqMKMiF5eqMpLROAiOC6V/pXT9vJuQ/9+ 1y74= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:X-Received:Received:Date:Message-ID:Subject:From:To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=JYvRSJvPq+QlAZR6Yv3xeAbnHvaYgRMFST8BTOJYs0JcgFLNnkC+99/2XD56Az 6T6r4ohueDvFodZlCM3+REbMC7h2ETp/wx4OJuO5iWEVpYFWl4yrg0C1z/g8rWC1 7IcVkXP8DBDqduLYIauFUi/7itfJgshwN1zoMYIcVUyJI=; Received: (qmail 9443 invoked by alias); 11 Feb 2013 00:19:29 -0000 Received: (qmail 9224 invoked by uid 22791); 11 Feb 2013 00:19:26 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-lb0-f169.google.com (HELO mail-lb0-f169.google.com) (209.85.217.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Feb 2013 00:19:20 +0000 Received: by mail-lb0-f169.google.com with SMTP id m4so4281532lbo.28 for ; Sun, 10 Feb 2013 16:19:18 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.112.100.199 with SMTP id fa7mr5006313lbb.28.1360541958825; Sun, 10 Feb 2013 16:19:18 -0800 (PST) Received: by 10.112.31.169 with HTTP; Sun, 10 Feb 2013 16:19:18 -0800 (PST) Date: Mon, 11 Feb 2013 00:19:18 +0000 Message-ID: Subject: [patch] partially fix libstdc++/56267 From: Jonathan Wakely To: "libstdc++" , gcc-patches Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org PR libstdc++/56267 * include/bits/hashtable.h (__cache_default): Check if hash function is copy assignable. * testsuite/23_containers/unordered_set/56267.cc: New. * testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust dg-error line number. * testsuite/23_containers/unordered_set/ not_default_constructible_hash_neg.cc: Likewise. Tested x86_64-linux, committed to trunk, will also commit to 4.7 soon. commit 4eb16ce9981130d6322f474d22f9c1aeba2b864d Author: Jonathan Wakely Date: Sun Feb 10 22:12:37 2013 +0000 PR libstdc++/56267 * include/bits/hashtable.h (__cache_default): Check if hash function is copy assignable. * testsuite/23_containers/unordered_set/56267.cc: New. * testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust dg-error line number. * testsuite/23_containers/unordered_set/ not_default_constructible_hash_neg.cc: Likewise. diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index 6515b71..b82cda3 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -43,8 +43,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION = __not_<__and_, // Mandatory to make local_iterator default - // constructible. + // constructible and assignable. is_default_constructible<_Hash>, + is_copy_assignable<_Hash>, // Mandatory to have erase not throwing. __detail::__is_noexcept_hash<_Tp, _Hash>>>; @@ -269,6 +270,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "Cache the hash code or make functors involved in hash code" " and bucket index computation default constructible"); + // When hash codes are not cached local iterator inherits from + // __hash_code_base above to compute node bucket index so it has to be + // assignable. + static_assert(__if_hash_not_cached< + is_copy_assignable<__hash_code_base>>::value, + "Cache the hash code or make functors involved in hash code" + " and bucket index computation copy assignable"); + public: template. + +// libstdc++/56267 + +#include + +struct hash : std::hash +{ + hash& operator=(const hash&) = delete; +}; + +int main() +{ + std::unordered_set s{ 0, 1, 2 }; + auto i = s.begin(0); + i = i; +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/instantiation_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/instantiation_neg.cc index 827691f..6712d62 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/instantiation_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/instantiation_neg.cc @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "with noexcept" "" { target *-*-* } 251 } +// { dg-error "with noexcept" "" { target *-*-* } 252 } #include diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/not_default_constructible_hash_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/not_default_constructible_hash_neg.cc index bd62a08..53a25bc 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/not_default_constructible_hash_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/not_default_constructible_hash_neg.cc @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "default constructible" "" { target *-*-* } 267 } +// { dg-error "default constructible" "" { target *-*-* } 268 } #include