From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111791 invoked by alias); 7 Feb 2018 17:35:03 -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 111760 invoked by uid 89); 7 Feb 2018 17:35:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=clues X-HELO: mail-qk0-f173.google.com Received: from mail-qk0-f173.google.com (HELO mail-qk0-f173.google.com) (209.85.220.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Feb 2018 17:35:01 +0000 Received: by mail-qk0-f173.google.com with SMTP id d125so2105267qkg.13 for ; Wed, 07 Feb 2018 09:35:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=FJjvpKhO+Ub6CVn2UoEkvWfy402QYjkXkNHwG7btVxY=; b=j7KaLqLgUWIRSF3TFfnKWmuZkNUk0vRFXC6S8VInX0wmIhvXoNLzczSHpUxIJKNzsb ySoNdWUFVO/dNAmoAx9A2i9OCnbvA6hjF9yBu40nwWmT53rSkv7uhYHohkDW1t2qq7Vx +ZVlUw818gdYxCHqzzj3ce1V3y4n893L+4UuRSVPP2jwt/nNIC4pYYyBglMZ9jmAAgmz JTgWXT0bi6cIt/e99wE9uAlzciXKrvtYIq/WPIyGEXrX/iD9EDedx9XwnrZoKwiEbO3z WEINKhOTgk3/cJT7S6trcADrYhL0hnEh26rHRtwh7BImbhUIpf08DWFRSmYU7XgW05MC UsAQ== X-Gm-Message-State: APf1xPC+glb8vvjNKqjx95O0Tr9MslpkhrFIC0UPTd0IPLhQeCu+3hYy AZcrsZLPAlyMbG1J9Tcu3sgibJzMGmhRlTfsCN0jlA== X-Google-Smtp-Source: AH8x227Vj5W5ynU7bFqacytE0DHs18BYHPUsKvOyC9VFviNWPoNjvbijaDN7vBFd9iFfF4KAY10bUUHsdEbcxinb+lE= X-Received: by 10.55.163.77 with SMTP id m74mr10248694qke.256.1518024900205; Wed, 07 Feb 2018 09:35:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.153.232 with HTTP; Wed, 7 Feb 2018 09:34:59 -0800 (PST) In-Reply-To: <874lmsyg0f.fsf@tromey.com> References: <1517996444-8605-1-git-send-email-yao.qi@linaro.org> <874lmsyg0f.fsf@tromey.com> From: Yao Qi Date: Wed, 07 Feb 2018 17:35:00 -0000 Message-ID: Subject: Re: [PATCH] New class allocate_on_obstack To: Tom Tromey Cc: GDB Patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00122.txt.bz2 On Wed, Feb 7, 2018 at 3:29 PM, Tom Tromey wrote: >>>>>> "Yao" =3D=3D Yao Qi writes: > > Yao> This patch adds a new class allocate_on_obstack, and let dwarf2_per_= objfile > Yao> inherit it, so that dwarf2_per_objfile is automatically allocated on > Yao> obstack, and "delete dwarf2_per_objfile" doesn't de-allocate any spa= ce. > > I still think it should be restricted to types with a trivial > destructor. Otherwise, someday, the lack of actual destruction is going > to cause a bug. > Can you give me some clues on how to do the restriction? I think I need to use std::enable_if and std::is_trivially_destructible, but don't know how t= o put them into the code. Lack of destruction causes a bug in any case. If object is allocated on he= ap, and don't do "delete p", the dtor isn't called and memory is leaked. I expect use "delete p" no matter where the object is allocated (on heap or on obstack). --=20 Yao (=E9=BD=90=E5=B0=A7)