From patchwork Thu Jun 10 10:28:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 55195 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 18D761007D3 for ; Thu, 10 Jun 2010 20:29:13 +1000 (EST) Received: (qmail 28979 invoked by alias); 10 Jun 2010 10:28:59 -0000 Received: (qmail 28864 invoked by uid 22791); 10 Jun 2010 10:28:56 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from vsmtp14.tin.it (HELO vsmtp14.tin.it) (212.216.176.118) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Jun 2010 10:28:46 +0000 Received: from [192.168.0.4] (79.33.220.215) by vsmtp14.tin.it (8.5.113) id 4BCE303705189A7F; Thu, 10 Jun 2010 12:28:43 +0200 Message-ID: <4C10BE5B.7010504@oracle.com> Date: Thu, 10 Jun 2010 12:28:43 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100317 SUSE/3.0.4-1.1.1 Thunderbird/3.0.4 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] libstdc++/44487 X-IsSubscribed: yes 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 Hi, tested x86_64-linux, committed to mainline and 4_5-branch (affects *only* c++0x mode and helps people experimenting with it). Paolo. ///////////////////// 2010-06-10 Paolo Carlini PR libstdc++/44487 * include/bits/stl_pair.h (pair(pair&&)): Remove. (pair(pair<_U1, _U2>&&): Use forward, consistently with Bullet 5 of LWG 1326. * include/std/tuple (tuple(pair<_U1, _U2>&&)): Likewise. * testsuite/20_util/pair/44487.cc: Add. * testsuite/20_util/tuple/cons/44487.cc: Likewise. * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust dg-warning line numbers. Index: include/std/tuple =================================================================== --- include/std/tuple (revision 160490) +++ include/std/tuple (working copy) @@ -341,7 +341,8 @@ template tuple(pair<_U1, _U2>&& __in) - : _Inherited(std::move(__in.first), std::move(__in.second)) { } + : _Inherited(std::forward<_U1>(__in.first), + std::forward<_U2>(__in.second)) { } tuple& operator=(const tuple& __in) Index: include/bits/stl_pair.h =================================================================== --- include/bits/stl_pair.h (revision 160490) +++ include/bits/stl_pair.h (working copy) @@ -120,10 +120,6 @@ : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { } - pair(pair&& __p) - : first(std::move(__p.first)), - second(std::move(__p.second)) { } - template pair(piecewise_construct_t, tuple<_Args1...> __first_args, @@ -141,8 +137,8 @@ #ifdef __GXX_EXPERIMENTAL_CXX0X__ template pair(pair<_U1, _U2>&& __p) - : first(std::move(__p.first)), - second(std::move(__p.second)) { } + : first(std::forward<_U1>(__p.first)), + second(std::forward<_U2>(__p.second)) { } pair& operator=(pair&& __p) Index: testsuite/20_util/tuple/cons/44487.cc =================================================================== --- testsuite/20_util/tuple/cons/44487.cc (revision 0) +++ testsuite/20_util/tuple/cons/44487.cc (revision 0) @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 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 + +int x, y; + +std::tuple +foo1() +{ + std::pair blah(x, y); + return blah; +} + +std::tuple +foo2() +{ + const std::pair blah(x, y); + return blah; +} + +std::tuple +foo3() +{ + std::pair blah(x, y); + return std::tuple(std::move(blah)); +} + +std::tuple +foo4() +{ + const std::pair blah(x, y); + return std::tuple(std::move(blah)); +} Index: testsuite/20_util/pair/44487.cc =================================================================== --- testsuite/20_util/pair/44487.cc (revision 0) +++ testsuite/20_util/pair/44487.cc (revision 0) @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 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 + +int x, y; + +std::pair +foo1() +{ + std::pair blah(x, y); + return blah; +} + +std::pair +foo2() +{ + const std::pair blah(x, y); + return blah; +} + +std::pair +foo3() +{ + std::pair blah(x, y); + return std::pair(std::move(blah)); +} + +std::pair +foo4() +{ + const std::pair blah(x, y); + return std::pair(std::move(blah)); +} Index: testsuite/20_util/weak_ptr/comparison/cmp_neg.cc =================================================================== --- testsuite/20_util/weak_ptr/comparison/cmp_neg.cc (revision 160490) +++ testsuite/20_util/weak_ptr/comparison/cmp_neg.cc (working copy) @@ -44,8 +44,8 @@ // { dg-warning "note" "" { target *-*-* } 324 } // { dg-warning "note" "" { target *-*-* } 423 } // { dg-warning "note" "" { target *-*-* } 862 } -// { dg-warning "note" "" { target *-*-* } 511 } +// { dg-warning "note" "" { target *-*-* } 512 } // { dg-warning "note" "" { target *-*-* } 1005 } // { dg-warning "note" "" { target *-*-* } 340 } // { dg-warning "note" "" { target *-*-* } 290 } -// { dg-warning "note" "" { target *-*-* } 201 } +// { dg-warning "note" "" { target *-*-* } 197 }