From patchwork Sun Apr 17 21:51:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 91598 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 12929B7009 for ; Mon, 18 Apr 2011 07:51:57 +1000 (EST) Received: (qmail 10495 invoked by alias); 17 Apr 2011 21:51:53 -0000 Received: (qmail 10475 invoked by uid 22791); 17 Apr 2011 21:51:51 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from smtp209.alice.it (HELO smtp209.alice.it) (82.57.200.105) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 17 Apr 2011 21:51:36 +0000 Received: from [192.168.1.4] (79.33.221.74) by smtp209.alice.it (8.5.124.08) id 4D498EF3065FCF54; Sun, 17 Apr 2011 23:51:34 +0200 Message-ID: <4DAB60DF.20305@oracle.com> Date: Sun, 17 Apr 2011 23:51:27 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: Re: [v3] libstdc++/48635 References: <4DA8E9D5.1090508@oracle.com> In-Reply-To: <4DA8E9D5.1090508@oracle.com> 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 ... applied mainline and branch this follow-up, see audit-trail for details. Tested x86_64-linux. Paolo. PS: Jon, looks like we are missing some constraining in the templated constructor and and assignment operator of the unique_ptr specialization? //////////////// 2011-04-17 Daniel Krugler Paolo Carlini PR libstdc++/48635 (again) * include/bits/unique_ptr.h (unique_ptr<>::unique_ptr(unique_ptr<>&&), unique_ptr<_Tp[]>::unique_ptr(unique_ptr<>&&), unique_ptr<>::operator=(unique_ptr<>&&), unique_ptr<_Tp[]>::operator=(unique_ptr<>&&)): Use forward<_Ep>, not forward<_Dp>, to forward the deleter. * testsuite/20_util/unique_ptr/assign/48635_neg.cc: New. Index: include/bits/unique_ptr.h =================================================================== --- include/bits/unique_ptr.h (revision 172617) +++ include/bits/unique_ptr.h (working copy) @@ -153,7 +153,7 @@ && std::is_convertible<_Ep, _Dp>::value))> ::type> unique_ptr(unique_ptr<_Up, _Ep>&& __u) - : _M_t(__u.release(), std::forward(__u.get_deleter())) + : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) { } #if _GLIBCXX_USE_DEPRECATED @@ -186,7 +186,7 @@ operator=(unique_ptr<_Up, _Ep>&& __u) { reset(__u.release()); - get_deleter() = std::forward(__u.get_deleter()); + get_deleter() = std::forward<_Ep>(__u.get_deleter()); return *this; } @@ -306,7 +306,7 @@ template unique_ptr(unique_ptr<_Up, _Ep>&& __u) - : _M_t(__u.release(), std::forward(__u.get_deleter())) + : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) { } // Destructor. @@ -326,7 +326,7 @@ operator=(unique_ptr<_Up, _Ep>&& __u) { reset(__u.release()); - get_deleter() = std::forward(__u.get_deleter()); + get_deleter() = std::forward<_Ep>(__u.get_deleter()); return *this; } Index: testsuite/20_util/unique_ptr/assign/48635_neg.cc =================================================================== --- testsuite/20_util/unique_ptr/assign/48635_neg.cc (revision 0) +++ testsuite/20_util/unique_ptr/assign/48635_neg.cc (revision 0) @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation +// +// 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 + +struct D; + +struct B +{ + B& operator=(D&) = delete; // { dg-error "declared here" } + + template + void operator()(T*) const {} +}; + +struct D : B { }; + +// libstdc++/48635 +void f() +{ + B b; + D d; + + std::unique_ptr ub(nullptr, b); + std::unique_ptr ud(nullptr, d); + ub = std::move(ud); +// { dg-error "use of deleted function" "" { target *-*-* } 189 } + + std::unique_ptr uba(nullptr, b); + std::unique_ptr uda(nullptr, d); + uba = std::move(uda); +// { dg-error "use of deleted function" "" { target *-*-* } 329 } +}