From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51421 invoked by alias); 7 Nov 2016 07:45:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 51405 invoked by uid 89); 7 Nov 2016 07:45:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=deallocate, transfer, Transfer X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Nov 2016 07:45:52 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D3BB63BEC1; Mon, 7 Nov 2016 07:45:51 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA77jmjN029036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 7 Nov 2016 02:45:51 -0500 Date: Mon, 07 Nov 2016 07:45:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA 01/14] Introduce py-ref.h Message-ID: <20161107074548.GA28389@host1.jankratochvil.net> References: <1478497656-11832-1-git-send-email-tom@tromey.com> <1478497656-11832-2-git-send-email-tom@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1478497656-11832-2-git-send-email-tom@tromey.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00131.txt.bz2 On Mon, 07 Nov 2016 06:47:23 +0100, Tom Tromey wrote: > + /* Copy another instance. */ > + gdbpy_reference &operator= (const gdbpy_reference &other) > + { > + Py_XDECREF (m_obj); > + m_obj = other.m_obj; > + if (m_obj != NULL) > + Py_INCREF (m_obj); > + return *this; > + } > + > + /* Transfer ownership from another instance. */ > + gdbpy_reference &operator= (gdbpy_reference &&other) > + { > + Py_XDECREF (m_obj); > + m_obj = other.m_obj; > + other.m_obj = NULL; > + return *this; > + } These two methods stale-reference / deallocate during self-assignments: gdbpyref = gdbpyref; gdbpyref = std::move (gdbpyref); std::unique_ptr<> and std::shared_ptr<> behave correctly in such cases. Jan