From patchwork Wed Mar 26 19:42:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 334058 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6BD051400A2 for ; Thu, 27 Mar 2014 06:42:28 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=orp3tdtbC9m0sht4ggiTqt9/QTwrp+ m84oois2DLaHgID0BgZkXvkgbDqn65UOSeGg6Hn6x10rMBwNP8GmDMCj7GB7Ubcn STg9uBmpV+Ebf6SX/dBTKHn4tdRj7QWotTS1RJiRkjlISdtBMQtIWuyTznXo08sl oBnlMPJfZ4oEg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=09QPKygg8Tvpce+XVcjqs5ys0XY=; b=nUE1 a0cVT503k+MDe11JiBvaCnm2zFdSSTIACurIgpFIyfdhLA8I+vWvR3Kyxax5rqjX KW2ZBXPfy9tj62AiiJ6NtnASw8mzTglqKlljObD1SHetDgpmHjm/Ms1BUNI5j+yc DT0wDjwac+LB23QDNplTn/t/4wp3BCcE7hLrZco= Received: (qmail 26069 invoked by alias); 26 Mar 2014 19:42:21 -0000 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 Received: (qmail 26051 invoked by uid 89); 26 Mar 2014 19:42:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 26 Mar 2014 19:42:20 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2QJgIlW023667 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 26 Mar 2014 15:42:18 -0400 Received: from localhost (vpn1-6-141.ams2.redhat.com [10.36.6.141]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s2QJgHmI006952; Wed, 26 Mar 2014 15:42:18 -0400 Date: Wed, 26 Mar 2014 19:42:17 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [patch] fix libstdc++/59548 Message-ID: <20140326194217.GB31837@redhat.com> References: <20140124200855.GA11829@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140124200855.GA11829@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) On 24/01/14 20:08 +0000, Jonathan Wakely wrote: >The debug-mode container base classes need copy constructors that >zero-init their members rather than copy them from the source. > >_Safe_unordered_container_base also needs its move constructor to be >non-throwing to fix some FAILs for the PR 55043 tests. > >Tested x86_64-linux, normal and debug modes, committed to trunk. >I also want to fix this on the branches once I've finished fixing 4.9 >regressions. Here's a smaller version of the trunk patch which I'm committing to the 4.8 branch. Tested x86_64-linux. (Aside: I wish "make check-debug" didn't take so long, and why does that target put conformance.exp in the RUNTESTFLAGS explicitly, so you can't do RUNTESTFLAGS=conformance.exp=23_containers/unordered_*" to re-run just a subset of the tests?) commit 39fadff8d22cf549968a2df4117111de4173db2f Author: Jonathan Wakely Date: Wed Mar 26 19:33:35 2014 +0000 PR libstdc++/59548 * include/debug/safe_unordered_base.h (_Safe_unordered_container_base): Define copy and move constructors that handle iterators correctly. * testsuite/23_containers/unordered_map/59548.cc: New. diff --git a/libstdc++-v3/include/debug/safe_unordered_base.h b/libstdc++-v3/include/debug/safe_unordered_base.h index 23026cb..35ce08b 100644 --- a/libstdc++-v3/include/debug/safe_unordered_base.h +++ b/libstdc++-v3/include/debug/safe_unordered_base.h @@ -133,9 +133,19 @@ namespace __gnu_debug protected: // Initialize with a version number of 1 and no iterators _Safe_unordered_container_base() - : _M_local_iterators(0), _M_const_local_iterators(0) + : _M_local_iterators(nullptr), _M_const_local_iterators(nullptr) { } + // Initialize with a version number of 1 and no iterators + _Safe_unordered_container_base(const _Safe_unordered_container_base&) + noexcept + : _Safe_unordered_container_base() { } + + _Safe_unordered_container_base(_Safe_unordered_container_base&& __x) + noexcept + : _Safe_unordered_container_base() + { this->_M_swap(__x); } + /** Notify all iterators that reference this container that the container is being destroyed. */ ~_Safe_unordered_container_base() diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc new file mode 100644 index 0000000..1e81bb7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// { dg-require-debug-mode "" } + +// Copyright (C) 2014 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// libstdc++/59548 + +#include + +int main() +{ + std::unordered_map foo{ {0,1} }; + auto i = foo.begin(); + { + auto bar = foo; + } + return i->first; +}