From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25426 invoked by alias); 25 Apr 2018 22:36:29 -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 25356 invoked by uid 89); 25 Apr 2018 22:36:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*RU:100.42.49.4, Hx-spam-relays-external:100.42.49.4, Hx-spam-relays-external:sk:cm10.we, H*RU:sk:cm10.we X-HELO: gateway21.websitewelcome.com Received: from gateway21.websitewelcome.com (HELO gateway21.websitewelcome.com) (192.185.45.91) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Apr 2018 22:36:24 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway21.websitewelcome.com (Postfix) with ESMTP id E833A400CE498 for ; Wed, 25 Apr 2018 17:36:22 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id BT1SfNB9R6il3BT1SfN5sR; Wed, 25 Apr 2018 17:36:22 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:47300 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fBT1S-002yyV-NH; Wed, 25 Apr 2018 17:36:22 -0500 From: Tom Tromey To: Simon Marchi Cc: Subject: Re: [PATCH 1/2] Introduce obstack_new, poison other "typed" obstack functions References: <1524685183-5553-1-git-send-email-simon.marchi@ericsson.com> Date: Wed, 25 Apr 2018 22:36:00 -0000 In-Reply-To: <1524685183-5553-1-git-send-email-simon.marchi@ericsson.com> (Simon Marchi's message of "Wed, 25 Apr 2018 15:39:42 -0400") Message-ID: <87sh7i7w2i.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fBT1S-002yyV-NH X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya) [97.122.176.117]:47300 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2018-04/txt/msg00529.txt.bz2 >>>>> "Simon" == Simon Marchi writes: Simon> This patch introduces a utility to make this pattern simpler: Simon> foo *f = obstack_new (); What about just having those types that can use this inherit from allocate_on_obstack? Then you can write: foo *f = new (obstack) foo (); It would be nice if we could have a global operator new that does this, but I don't think it is possible to have one that is limited to is_trivially_constructible classes. Maybe is_trivially_destructible is also needed somehow since an obstack isn't going to run those destructors. Not sure how to manage this either, right now allocate_on_obstack just assumes you know what you're up to. Simon> To help catch places where we would forget to call new when allocating Simon> such an object on an obstack, this patch also poisons some other methods Simon> of allocating an instance of a type on an obstack: This is excellent. Tom