From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20355 invoked by alias); 18 Oct 2011 17:50:36 -0000 Received: (qmail 20326 invoked by uid 22791); 18 Oct 2011 17:50:33 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Oct 2011 17:50:14 +0000 Received: from wpaz17.hot.corp.google.com (wpaz17.hot.corp.google.com [172.24.198.81]) by smtp-out.google.com with ESMTP id p9IHoCcW026445 for ; Tue, 18 Oct 2011 10:50:12 -0700 Received: from ggnk3 (ggnk3.prod.google.com [10.218.97.67]) by wpaz17.hot.corp.google.com with ESMTP id p9IHkTih029139 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 18 Oct 2011 10:50:12 -0700 Received: by ggnk3 with SMTP id k3so1231873ggn.9 for ; Tue, 18 Oct 2011 10:50:12 -0700 (PDT) Received: by 10.151.92.13 with SMTP id u13mr3314700ybl.83.1318960212262; Tue, 18 Oct 2011 10:50:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.151.92.13 with SMTP id u13mr3314683ybl.83.1318960212030; Tue, 18 Oct 2011 10:50:12 -0700 (PDT) Received: by 10.151.26.19 with HTTP; Tue, 18 Oct 2011 10:50:11 -0700 (PDT) In-Reply-To: <20111018194123.1d5103e320cbed0a35363349@starynkevitch.net> References: <20111018171201.361304028ab94f102f827bd2@starynkevitch.net> <20111018191350.470cd6b1cd291373d5ff3f2c@starynkevitch.net> <20111018194123.1d5103e320cbed0a35363349@starynkevitch.net> Date: Tue, 18 Oct 2011 18:11:00 -0000 Message-ID: Subject: Re: adding destroyable objects into Ggc From: Ian Lance Taylor To: Basile Starynkevitch Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg00289.txt.bz2 On Tue, Oct 18, 2011 at 10:41 AM, Basile Starynkevitch wrote: > On Tue, 18 Oct 2011 10:36:08 -0700 > Ian Lance Taylor wrote: > >> On Tue, Oct 18, 2011 at 10:13 AM, Basile Starynkevitch >> wrote: >> > >> > Still, I find strange that while some very smart & nice GCC guys want = to get rid of Ggc, >> > no patch made into the trunk towards that goal (which I Basile dislike= and don't share, >> > so don't expect me Basile to work on this.). >> >> I've put a lot of work into making it possible to build gcc as a C++ pro= gram. > > I do know that, and as many GCC developers I am grateful to you Ian for y= our big work. > > However, I don't know very well auto_ptr. =A0Could you explain to use how= do they deal with > *circular* memory references.... (perhaps by taking as examples code insi= de GCC). > My feeling is that auto_ptr is not able to deal with them, but I'll be de= lighted to be > proven wrong. auto_ptr is confusing and hard to use. Don't think about it. I think a better approach here is likely to be a reference counted shared_ptr for the most general case. It's true that it works poorly with cycles, but gcc data structures are only occasionally cyclical. Also, I think that actually many cases in gcc do not require shared_ptr. Instead, we can think of terms of pools, with the smart pointers being aware of which pool they are associated with. Then we can detect at compile time an accidental use of a pointer to one pool being assigned to a pointer to a different pool. Before we introduced garbage collection, gcc used pools (well, obstacks), but there were severe problems because pointers to one pool would be assigned to a pointer to a different pool and then become dangling pointers when the first pool was deleted. C++ will let us avoid that problem. Ian