From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 41F133894C35 for ; Tue, 13 Jul 2021 20:02:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 41F133894C35 Received: by mail-qk1-x729.google.com with SMTP id s193so2152041qke.4 for ; Tue, 13 Jul 2021 13:02:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/WIDnsouT2/oYnYXwHFpnhiJqjuiZ+1wSmVu9IdM81o=; b=S5y0msPDodR+7O4K9RAPksDgpWFq9CFP6SQ+nrLxTDWoqyKk7TPwK+Pv2DD9NeMAnj zPLtzlOinx3Bj/XrNaMDDDj6rIp43dQWliQwvm+Yur8CBOMlobYVNBCd7Dc7Er48d2x1 3AT42Ifl5RMWHfHaoqKnqrgIjWzpNPF0ApDYyyRErGyyKb5XZeR9UXZOk9lGIK/Mdxui py9reWBWfkHwFf+CPihZ7Z8AdL56nJ+mmXkaWq7kvSNKyJgJ30QCczhpHDkS4/Y+JsN7 VHwi7KMsChM2n0xC5gvdjWntK/uj5LKAKCACxGst5Lud8Ztdc5u+0LTItx5zCNrEZeuq iFrA== X-Gm-Message-State: AOAM5303ub2h1Qga9BJcmIo36kBEYyq990lJQEBGQUdYEMAMU4u/CoxE uZAk+ZVUicWbpDSS4Lc4bcYzFjnqy2g= X-Google-Smtp-Source: ABdhPJwLhXh2bRPW3s272liqrf1HD12jBHWc52h3oHHI5SmNZRB1RCvEg1hoUu9AUlT+wNpXZfzMfA== X-Received: by 2002:a05:620a:4015:: with SMTP id h21mr5904701qko.256.1626206542724; Tue, 13 Jul 2021 13:02:22 -0700 (PDT) Received: from [192.168.0.41] (75-166-102-22.hlrn.qwest.net. [75.166.102.22]) by smtp.gmail.com with ESMTPSA id r2sm8413032qkf.94.2021.07.13.13.02.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jul 2021 13:02:22 -0700 (PDT) Subject: Re: [PING][PATCH] define auto_vec copy ctor and assignment (PR 90904) To: Jason Merrill , Jonathan Wakely , Richard Biener Cc: gcc-patches References: <91545a73-12af-33b2-c6e7-119b5a21de60@gmail.com> <4d503394-4e82-1d36-41ca-34315042775b@redhat.com> <49569f1d-9856-55c7-b9e9-578bbd7c7b7a@gmail.com> <390c6652-0a1f-e8c4-d70d-56ced2f7b0fb@gmail.com> <0ee2488c-04a1-df3b-dd4f-92eec51a4ab2@redhat.com> From: Martin Sebor Message-ID: <7ebb37f3-76c3-8e00-7852-c93bf142043a@gmail.com> Date: Tue, 13 Jul 2021 14:02:20 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <0ee2488c-04a1-df3b-dd4f-92eec51a4ab2@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jul 2021 20:02:24 -0000 On 7/13/21 12:37 PM, Jason Merrill wrote: > On 7/13/21 10:08 AM, Jonathan Wakely wrote: >> On Mon, 12 Jul 2021 at 12:02, Richard Biener wrote: >>> Somebody with more C++ knowledge than me needs to approve the >>> vec.h changes - I don't feel competent to assess all effects of the >>> change. >> >> They look OK to me except for: >> >> -extern vnull vNULL; >> +static constexpr vnull vNULL{ }; >> >> Making vNULL have static linkage can make it an ODR violation to use >> vNULL in templates and inline functions, because different >> instantiations will refer to a different "vNULL" in each translation >> unit. > > The ODR says this is OK because it's a literal constant with the same > value (6.2/12.2.1). > > But it would be better without the explicit 'static'; then in C++17 it's > implicitly inline instead of static. I'll remove the static. > > But then, do we really want to keep vNULL at all?  It's a weird blurring > of the object/pointer boundary that is also dependent on vec being a > thin wrapper around a pointer.  In almost all cases it can be replaced > with {}; one exception is == comparison, where it seems to be testing > that the embedded pointer is null, which is a weird thing to want to test. The one use case I know of for vNULL where I can't think of an equally good substitute is in passing a vec as an argument by value. The only way to do that that I can think of is to name the full vec type (i.e., the specialization) which is more typing and less generic than vNULL. I don't use vNULL myself so I wouldn't miss this trick if it were to be removed but others might feel differently. If not, I'm all for getting rid of vNULL but with over 350 uses of it left, unless there's some clever trick to make the removal (mostly) effortless and seamless, I'd much rather do it independently of this initial change. I also don't know if I can commit to making all this cleanup. > > Somewhat relatedly, use of vec variables or fields seems almost > always a mistake, as they need explicit .release() that could be > automatic with auto_vec, and is easy to forget.  For instance, the > recursive call in get_all_loop_exits returns a vec that is never > released.  And I see a couple of leaks in the C++ front end as well. I agree. The challenge I ran into with changing vec fields is with code that uses the vec member as a reference to auto_vec. This is the case in gcc/ipa-prop.h, for instance. Those instances could be changed to auto_vec references or pointers but again it's a more intrusive change than the simple replacements I was planning to make in this first iteration. So in summary, I agree with the changes you suggest. Given their scope I'd prefer not to make them in the same patch, and rather make them at some point in the future when I or someone else has the time and energy. I'm running out. Martin