From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id ADB5F3858D20; Thu, 10 Nov 2022 16:33:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADB5F3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668098030; bh=a9ZBLkA0gkcRJC9HBNU0eltaCEQz3018lhIZHhe7yTo=; h=From:To:Subject:Date:From; b=IwWsG62aq6BldqeneAdZaqytt1RN+34+rjJdZX2SZc3pivht1mNF2TxA7JDQGtd5J pARs42SYC5vM5hjUycOcqeNoCNvJcHyDHDtIysSKKe/gAVt5crVayZlKSyYfDntKkp vCS3IQLkQlS6BdTBw/bl5HISF/c1pL2fk61/gz88= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: clear other.m_cached_id in frame_info_ptr's move ctor X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 041de3d73aa121f2ff0c077213598963bfb34b79 X-Git-Newrev: 70f479c6f8bf976ca680fd53d655ccec56b3f12e Message-Id: <20221110163350.ADB5F3858D20@sourceware.org> Date: Thu, 10 Nov 2022 16:33:50 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D70f479c6f8bf= 976ca680fd53d655ccec56b3f12e commit 70f479c6f8bf976ca680fd53d655ccec56b3f12e Author: Simon Marchi Date: Fri Oct 21 11:57:15 2022 -0400 gdb: clear other.m_cached_id in frame_info_ptr's move ctor =20 We do it in the move assignment operator, so I think it makes sense to do it here too for consistency. I don't think it's absolutely necessary to clear the other object's fields (in other words, copy constructor and move constructor could be the same), as there is no exclusive resource being transfered. The important thing is to leave the moved-from object in an unknown, but valid state. But still, I think that clearing the fields of the moved-from object is not a bad idea, it helps ensure we don't rely on the moved-from object after. =20 Change-Id: Iee900ff9d25dad51d62765d694f2e01524351340 Reviewed-By: Bruno Larsen Diff: --- gdb/frame-info.h | 1 + 1 file changed, 1 insertion(+) diff --git a/gdb/frame-info.h b/gdb/frame-info.h index 665f4bdae3b..7159f82b196 100644 --- a/gdb/frame-info.h +++ b/gdb/frame-info.h @@ -71,6 +71,7 @@ public: : m_ptr (other.m_ptr), m_cached_id (other.m_cached_id) { other.m_ptr =3D nullptr; + other.m_cached_id =3D null_frame_id; frame_list.push_back (*this); }