From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31291 invoked by alias); 2 Aug 2017 08:14:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 31238 invoked by uid 89); 2 Aug 2017 08:14:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=Hope X-HELO: mail-qk0-f196.google.com Received: from mail-qk0-f196.google.com (HELO mail-qk0-f196.google.com) (209.85.220.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Aug 2017 08:14:35 +0000 Received: by mail-qk0-f196.google.com with SMTP id m84so3867577qki.5 for ; Wed, 02 Aug 2017 01:14:35 -0700 (PDT) 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; bh=PLsCYV06CAVU1NNzeE8NO221MsVkaemwixNC2d8s20I=; b=ZyeixMhKkHxNIcs13iVDKm8J9XM9/50zo0s34OrWNJjm0ugZSvx1cRLqyOts1MV5D2 ouUX2Bb5R//NVlHmKwlpJZwN+Po8Ta+hdIBnIlPpmnKqH+plGrSdvAKjJ1JSwwzcMJ6g jLv6SuXP/1I0ODsFnGDHHrTioypEy1iMLt0j70oskRS1oiBochyAu9GIIVctBwXZjOIq MQM+w3e35diXAtQhm+Ned9p38twb7NcHzmHjMeTB6ODJUAnzA/vQWWoqjaFwqX05A4JF oOIza6mQndzYqxazyho5HSTr5qdIAtRgeuqkNSPCN9rdOm2mwSFhW0DyKuRBKlh42I2Y rSYA== X-Gm-Message-State: AIVw112erb8TC9+5gjXYSbB62O8u7VfELjzeBhGannwYyBzFGVr4JWhW PWroufAE7xKV4nh4RfQRDuEA4dUMvg== X-Received: by 10.55.2.193 with SMTP id v62mr25638518qkg.231.1501661673992; Wed, 02 Aug 2017 01:14:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.43.35 with HTTP; Wed, 2 Aug 2017 01:14:33 -0700 (PDT) In-Reply-To: <1501598453.4181.10.camel@redhat.com> References: <20170731234607.21952-1-tbsaunde+gcc@tbsaunde.org> <20170731234607.21952-2-tbsaunde+gcc@tbsaunde.org> <1501598453.4181.10.camel@redhat.com> From: Richard Biener Date: Wed, 02 Aug 2017 08:14:00 -0000 Message-ID: Subject: Re: [PATCH 1/2] add unique_ptr header To: David Malcolm Cc: tbsaunde+gcc@tbsaunde.org, GCC Patches , palves@redhat.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00147.txt.bz2 On Tue, Aug 1, 2017 at 4:40 PM, David Malcolm wrote > On Mon, 2017-07-31 at 19:46 -0400, tbsaunde+gcc@tbsaunde.org wrote: >> From: Trevor Saunders >> >> For most of the history of this see >> https://sourceware.org/ml/gdb-patches/2016-10/msg00223.html >> The changes are mostly s/gdb/gtl/g >> >> include/ChangeLog: >> >> 2017-07-29 Trevor Saunders >> >> * unique-ptr.h: New file. >> --- >> include/unique-ptr.h | 386 >> +++++++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 386 insertions(+) >> create mode 100644 include/unique-ptr.h >> >> diff --git a/include/unique-ptr.h b/include/unique-ptr.h >> new file mode 100644 >> index 00000000000..7903a5abefe >> --- /dev/null >> +++ b/include/unique-ptr.h >> @@ -0,0 +1,386 @@ >> +/* gtl::unique_ptr, a simple std::unique_ptr replacement for C++03. >> + >> + Copyright (C) 2007-2016 Free Software Foundation, Inc. >> + >> + This file is part of GCC. >> + >> + This program is free software; you can redistribute it and/or >> modify >> + it under the terms of the GNU General Public License as published >> by >> + the Free Software Foundation; either version 3 of the License, or >> + (at your option) any later version. >> + >> + This program is distributed in the hope that it will be useful, >> + but WITHOUT ANY WARRANTY; without even the implied warranty of >> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + GNU General Public License for more details. >> + >> + You should have received a copy of the GNU General Public License >> + along with this program. If not, see > s/>. */ >> + >> +/* gtl::unique_ptr defines a C++ owning smart pointer that exposes a >> + subset of the std::unique_ptr API. >> + >> + In fact, when compiled with a C++11 compiler, gtl::unique_ptr >> + actually _is_ std::unique_ptr. When compiled with a C++03 >> compiler >> + OTOH, it's an hand coded std::unique_ptr emulation that assumes >> + code is correct and doesn't try to be too smart. > > The comments talk about C++03 (presumably due to the gdb heritage of > this code), but gcc's minimum requirement is for C++98. It's actually C++04 but I don't remember the details. It happens to work with GCC 3.4 and thus C++98 though. Richard. > Does this code work with C++98? If so, presumably this comment should > state that (presumably by just writing "C++98 or C++03" wherever you > say "C++03"). > > [...snip...] > > Could the patch add a set of selftests for the new code? (e.g. assert > the number of times that a destructor is called, for various test > classes in various situations). This would also give a handy way to > run the pertinent code relatively quickly under valgrind (via "make > selftest-valgrind"). > > I'm not a global reviewer, so treat these as suggestions. > > Hope this is helpful > Dave