From patchwork Fri Jun 14 23:40:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 251561 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 207E82C0096 for ; Sat, 15 Jun 2013 09:41:17 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=MTQ2J34VfE8EzgAAhs3s6GjI3561IQh2awnblrzLryt o2bDgwWoGGrR/OBMnB5072yV6nad6j4QPkt0c6gzhthIGUXtQNX0gSU228VFKlm2 8/6/b2OXWMgFLolph43N4zMarZSP4agcTB+oiPDSCeLWD7UNOIjhni+palMGpR5c = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=tNnZceb1uo+w0+BJ7/raWfbeg0M=; b=IFn/hih/wQcKBdGyX gahAMHo5TxBQ3IqTCGXUn6m/qHdr0BWfFkwedWL5TNwOrh0YvbHHjIvbbDQbFWd8 DUjvizGsXShDv67i20zBk6P10kpa5GaTCMEGtFoL1iLWsYbf8Eow5wFeiP6nygZa 11tMiclIkvDS9BKiriP/h1rFck= Received: (qmail 2361 invoked by alias); 14 Jun 2013 23:41:02 -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 2336 invoked by uid 89); 14 Jun 2013 23:41:01 -0000 X-Spam-SWARE-Status: No, score=-5.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 14 Jun 2013 23:41:00 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r5ENevLV031257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 14 Jun 2013 23:40:58 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5ENeuQN008724 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 14 Jun 2013 23:40:56 GMT Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5ENeuAk024590; Fri, 14 Jun 2013 23:40:56 GMT Received: from poldo4.casa (/79.52.234.152) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 14 Jun 2013 16:40:55 -0700 Message-ID: <51BBAA05.4030004@oracle.com> Date: Sat, 15 Jun 2013 01:40:53 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] libstdc++/57619 X-Virus-Found: No Hi, tested x86_64-linux, committed mainline and 4_8-branch. Thanks, Paolo. ////////////////////// 2013-06-15 Paolo Carlini PR libstdc++/57619 * include/bits/unordered_map.h (unordered_map<>::insert, unordered_multimap<>::insert): Use std::forward, not std::move. * testsuite/23_containers/unordered_map/insert/57619.C: New. * testsuite/23_containers/unordered_multimap/insert/57619.C: Likewise. Index: include/bits/unordered_map.h =================================================================== --- include/bits/unordered_map.h (revision 200109) +++ include/bits/unordered_map.h (working copy) @@ -397,7 +397,7 @@ _Pair&&>::value>::type> std::pair insert(_Pair&& __x) - { return _M_h.insert(std::move(__x)); } + { return _M_h.insert(std::forward<_Pair>(__x)); } //@} //@{ @@ -431,7 +431,7 @@ _Pair&&>::value>::type> iterator insert(const_iterator __hint, _Pair&& __x) - { return _M_h.insert(__hint, std::move(__x)); } + { return _M_h.insert(__hint, std::forward<_Pair>(__x)); } //@} /** @@ -1093,7 +1093,7 @@ _Pair&&>::value>::type> iterator insert(_Pair&& __x) - { return _M_h.insert(std::move(__x)); } + { return _M_h.insert(std::forward<_Pair>(__x)); } //@} //@{ @@ -1125,7 +1125,7 @@ _Pair&&>::value>::type> iterator insert(const_iterator __hint, _Pair&& __x) - { return _M_h.insert(__hint, std::move(__x)); } + { return _M_h.insert(__hint, std::forward<_Pair>(__x)); } //@} /** Index: testsuite/23_containers/unordered_map/insert/57619.C =================================================================== --- testsuite/23_containers/unordered_map/insert/57619.C (revision 0) +++ testsuite/23_containers/unordered_map/insert/57619.C (working copy) @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + { + std::unordered_map mymap; + std::pair mypair{std::string("key"), + std::string("value")}; + mymap.insert(mypair); + + VERIFY( mypair.first.length() && mypair.second.length() ); + } + + { + std::unordered_map mymap; + std::pair mypair{std::string("key"), + std::string("value")}; + mymap.insert(mymap.begin(), mypair); + + VERIFY( mypair.first.length() && mypair.second.length() ); + } +} + +int main() +{ + test01(); + return 0; +} Index: testsuite/23_containers/unordered_multimap/insert/57619.C =================================================================== --- testsuite/23_containers/unordered_multimap/insert/57619.C (revision 0) +++ testsuite/23_containers/unordered_multimap/insert/57619.C (working copy) @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + { + std::unordered_multimap mymmap; + std::pair mypair{std::string("key"), + std::string("value")}; + mymmap.insert(mypair); + + VERIFY( mypair.first.length() && mypair.second.length() ); + } + + { + std::unordered_multimap mymmap; + std::pair mypair{std::string("key"), + std::string("value")}; + mymmap.insert(mymmap.begin(), mypair); + + VERIFY( mypair.first.length() && mypair.second.length() ); + } +} + +int main() +{ + test01(); + return 0; +}