From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8025 invoked by alias); 18 Dec 2011 12:02:47 -0000 Received: (qmail 8009 invoked by uid 22791); 18 Dec 2011 12:02:46 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Dec 2011 12:02:33 +0000 From: "daniel.kruegler at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/51609] New: [C++11] unique_ptr::reset rejects cv-compatible argument pointers Date: Sun, 18 Dec 2011 12:36:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: daniel.kruegler at googlemail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-12/txt/msg01992.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D51609 Bug #: 51609 Summary: [C++11] unique_ptr::reset rejects cv-compatible argument pointers Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: daniel.kruegler@googlemail.com gcc 4.7.0 20111210 (experimental) in C++0x mode rejects the following code:= =20 //--------------- #include struct T {}; T* bar() { return new T{}; } int main() { std::unique_ptr p; p.reset(bar()); // # Line 10 } //--------------- "main.cpp||In function 'int main()':| main.cpp|10|error: use of deleted function 'void std::unique_ptr<_Tp [], _Dp>::reset(_Up) [with _Up =3D T*; _Tp =3D const T; _Dp =3D std::default_de= lete]'| [..]include\c++\4.7.0\bits\unique_ptr.h|392|error: declared here| " This behaviour is in conflict with the standard. Referring to N3290 [unique.ptr.runtime] p1 b2: "=E2=80=94 Pointers to types derived from T are rejected by the constructor= s, and by reset." Further inspection of [unique.ptr.runtime.modifiers] does not reveal any further constraints that could invalidate the assumption that reset should accept the pointer to non-const T. This should also not be invalidated by t= he constraints on default_delete::operator(), because the deleter will al= ways be called on the internally hold pointer which has the correct type. In regard to the seemingly difference to the constructor constraints of [unique.ptr.runtime.ctor] p1 I would like to point to a new LWG issue: http://cplusplus.github.com/LWG/lwg-active.html#2118