From patchwork Sun Mar 4 12:56:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 144510 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 B469EB6F9D for ; Sun, 4 Mar 2012 23:56:53 +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=1331470616; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Received-SPF:Received:MIME-Version: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; bh=RwjH6n7qYP3RvC6kGjCcOLoyWTM=; b=wIko+W7LsYjzc1P 0wlatJBAwD1lXOZ/bj6yglXXdSymXjpDOrhGnfn5jlb6O6y0VcF10sGmBwyQA4+5 l1/xvLgbKKOspbb0+LUcd2Ivql5Ufh7CQy6W0JPlx/wTr6aMLIyVaGkGLZ+EmifL a0+ebQEyaoBu9qZNynQPlNlBu0LE= 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:Received-SPF:Authentication-Results:Received:MIME-Version: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=sXj6t3s+oWpHBzGCoUX5Nvb7+6/qTzsipwl6iVI8zYpDHIXhiIpUvMPBh5hb35 qAOgWFl0dRxG9WARqyj+gY2Xh38pblc/bX1JPdEb85NVNXciZO8zKkWEedWh9hFQ 7kERMPm/arYOhizQ3d1Zs/DWBueU6cltzGFbZVYsjck9k=; Received: (qmail 30310 invoked by alias); 4 Mar 2012 12:56:46 -0000 Received: (qmail 30296 invoked by uid 22791); 4 Mar 2012 12:56:45 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-lpp01m010-f47.google.com (HELO mail-lpp01m010-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 04 Mar 2012 12:56:29 +0000 Received: by lagw12 with SMTP id w12so4120273lag.20 for ; Sun, 04 Mar 2012 04:56:27 -0800 (PST) Received-SPF: pass (google.com: domain of jwakely.gcc@gmail.com designates 10.112.45.104 as permitted sender) client-ip=10.112.45.104; Authentication-Results: mr.google.com; spf=pass (google.com: domain of jwakely.gcc@gmail.com designates 10.112.45.104 as permitted sender) smtp.mail=jwakely.gcc@gmail.com; dkim=pass header.i=jwakely.gcc@gmail.com Received: from mr.google.com ([10.112.45.104]) by 10.112.45.104 with SMTP id l8mr2057500lbm.92.1330865787906 (num_hops = 1); Sun, 04 Mar 2012 04:56:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.45.104 with SMTP id l8mr1700131lbm.92.1330865787787; Sun, 04 Mar 2012 04:56:27 -0800 (PST) Received: by 10.112.117.129 with HTTP; Sun, 4 Mar 2012 04:56:27 -0800 (PST) Date: Sun, 4 Mar 2012 12:56:27 +0000 Message-ID: Subject: fix libstdc++/52433 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++/52433 * include/debug/safe_iterator.h (_Safe_iterator): Add move constructor and move assignment operator. * testsuite/23_containers/vector/debug/52433.cc: New. Tested 'make check check-debug' on x86_64 and committed to trunk. I plan to fix this for 4.7.1 and 4.6.4 as well diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h index e7cfe9c..65dff55 100644 --- a/libstdc++-v3/include/debug/safe_iterator.h +++ b/libstdc++-v3/include/debug/safe_iterator.h @@ -169,6 +169,19 @@ namespace __gnu_debug ._M_iterator(__x, "other")); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Move construction. + * @post __x is singular and unattached + */ + _Safe_iterator(_Safe_iterator&& __x) : _M_current() + { + std::swap(_M_current, __x._M_current); + this->_M_attach(__x._M_sequence); + __x._M_detach(); + } +#endif + /** * @brief Converting constructor from a mutable iterator to a * constant iterator. @@ -208,6 +221,22 @@ namespace __gnu_debug return *this; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Move assignment. + * @post __x is singular and unattached + */ + _Safe_iterator& + operator=(_Safe_iterator&& __x) + { + _M_current = __x._M_current; + _M_attach(__x._M_sequence); + __x._M_detach(); + __x._M_current = _Iterator(); + return *this; + } +#endif + /** * @brief Iterator dereference. * @pre iterator is dereferenceable @@ -422,7 +451,9 @@ namespace __gnu_debug /// Is this iterator equal to the sequence's before_begin() iterator if /// any? bool _M_is_before_begin() const - { return _BeforeBeginHelper<_Sequence>::_M_Is(base(), _M_get_sequence()); } + { + return _BeforeBeginHelper<_Sequence>::_M_Is(base(), _M_get_sequence()); + } }; template diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc new file mode 100644 index 0000000..f1f5917 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2012 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// PR libstdc++/52433 + +#include + +struct X +{ + std::vector::iterator i; + + X() = default; + X(const X&) = default; + X(X&&) = default; + X& operator=(const X&) = default; + X& operator=(X&&) = default; +}; + +X test01() +{ + X x; + x = X(); + return x; +} +