From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68751 invoked by alias); 31 Dec 2017 13:49:44 -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 68726 invoked by uid 89); 31 Dec 2017 13:49:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL,BAYES_00,BODY_8BITS,GARBLED_BODY,GIT_PATCH_1,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 31 Dec 2017 13:49:42 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id vBVDnZmV001537 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 31 Dec 2017 08:49:40 -0500 Received: by simark.ca (Postfix, from userid 112) id E25461E5A6; Sun, 31 Dec 2017 08:49:35 -0500 (EST) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 1FD0E1E4C0; Sun, 31 Dec 2017 08:49:25 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Sun, 31 Dec 2017 13:49:00 -0000 From: Simon Marchi To: =?UTF-8?Q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB_=D0=9A=D1=80=D1=8E=D0=BA?= =?UTF-8?Q?=D0=BE=D0=B2?= Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Make dtor of mapped_index_base virtual In-Reply-To: References: Message-ID: <85ac4a723847708e1f2b49f90038a936@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.2 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sun, 31 Dec 2017 13:49:36 +0000 X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00538.txt.bz2 On 2017-12-31 05:12, Павел Крюков wrote: > Hi Simon > >> Do you get a build error or something? > > Yes, I get a build error with Clang: > > dwarf2read.c:25409:5: error: destructor called on non-final > 'mapped_index' > that > has virtual functions but non-virtual destructor > [-Werror,-Wdelete-non-virtual-dtor] > data->index_table->~mapped_index (); > >> Since the goal is that we don't delete through a pointer of this >> class, does > the destructor need to be virtual (not that it would hurt anything)? > > Just to handle the case if someone would delete through a pointer to > "mapped_index_base" class. > > Thanks, Hi Pavel, I think this warning was fixed by the following commit: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=fc898b42e355fef58e6a029799fdd71b9dda5dc6 We don't want anything deleting through a pointer of the base class, because (for now) instances of the two child classes (mapped_index and mapped_debug_names) are allocated differently. One is allocated on the objfile obstack (some kind of manual memory block allocation) and the other is allocated with new. Trying to delete or manually call the destructor through a pointer to mapped_index_base would do the wrong thing for one of the two children. So it's on purpose that mapped_index_base's destructor is hidden, and it doesn't matter whether or not it is virtual. Thanks, Simon