From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 01D653857C77 for ; Thu, 27 May 2021 19:33:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 01D653857C77 Received: by mail-ot1-x329.google.com with SMTP id i12-20020a05683033ecb02903346fa0f74dso1270770otu.10 for ; Thu, 27 May 2021 12:33:11 -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:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cXgrhEtn3BtdfndVx11qAb9dDICqsCL9C/d5LQ7H3ps=; b=QEcU232DAF7pDIi/MO2d6ih8ut3wjRwO6BhCnCiLVlbc3XcLA4KdtZhIqdSN9OoHjo wJSexdXuzID7ILGB/Vagwkczys+wxwNNGh7rKT6P8ZGCJB4nsZFNzAKyY0CeCvd21+4o qCx+0+4avNvukdfpXYJ+jLBRxtnQrB2qGxIOTsCZE1V041SmI9oSEfdjXjamTXyy13wp SPJeAVIvDG76IbfxL/0YT4QRq115V4SZkoYUo7yCV+poI51IIdV81Zkz05s+4SClfX9J MMDamsn5VcF4+Jtcp7HoqUlr9aJVZ0qzlM52FHZWs9Ivv6F8bjWofcyuQh4z0R3SpeIh Rxqg== X-Gm-Message-State: AOAM532K1SIvg+cfDjeKYsS0KwysAeY7Eryr8GdWOA2D2FIwFm9Igdkx Vnv+KtxwyBCJX0qNg06B2BAs74carY0= X-Google-Smtp-Source: ABdhPJx7dRotFOHjGEYieuNAj2GdrCQ7pwuylP39zuFusF/MHTvzmgJhp+G25ys2RdbCNRawlWsEnA== X-Received: by 2002:a9d:4d84:: with SMTP id u4mr4053505otk.136.1622143991202; Thu, 27 May 2021 12:33:11 -0700 (PDT) Received: from [192.168.0.41] (174-16-126-108.hlrn.qwest.net. [174.16.126.108]) by smtp.gmail.com with ESMTPSA id i133sm638524oia.2.2021.05.27.12.33.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 May 2021 12:33:10 -0700 (PDT) Subject: [PING 3][PATCH] define auto_vec copy ctor and assignment (PR 90904) From: Martin Sebor To: Jason Merrill Cc: Richard Biener , gcc-patches References: <91545a73-12af-33b2-c6e7-119b5a21de60@gmail.com> Message-ID: <62ea4482-5d7e-6a3d-dd05-b27083c35696@gmail.com> Date: Thu, 27 May 2021 13:33:09 -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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Thu, 27 May 2021 19:33:14 -0000 Jason, I wonder if you could review this patch that Richard has apparently decided to defer to others. https://gcc.gnu.org/pipermail/gcc-patches/2021-April/568901.html Thanks On 5/11/21 2:02 PM, Martin Sebor wrote: > Ping 2: > https://gcc.gnu.org/pipermail/gcc-patches/2021-April/568901.html > > > On 5/3/21 3:50 PM, Martin Sebor wrote: >> Ping: >> >> https://gcc.gnu.org/pipermail/gcc-patches/2021-April/568901.html >> >> On 4/27/21 9:52 AM, Martin Sebor wrote: >>> On 4/27/21 8:04 AM, Richard Biener wrote: >>>> On Tue, Apr 27, 2021 at 3:59 PM Martin Sebor wrote: >>>>> >>>>> On 4/27/21 1:58 AM, Richard Biener wrote: >>>>>> On Tue, Apr 27, 2021 at 2:46 AM Martin Sebor via Gcc-patches >>>>>> wrote: >>>>>>> >>>>>>> PR 90904 notes that auto_vec is unsafe to copy and assign because >>>>>>> the class manages its own memory but doesn't define (or delete) >>>>>>> either special function.  Since I first ran into the problem, >>>>>>> auto_vec has grown a move ctor and move assignment from >>>>>>> a dynamically-allocated vec but still no copy ctor or copy >>>>>>> assignment operator. >>>>>>> >>>>>>> The attached patch adds the two special functions to auto_vec along >>>>>>> with a few simple tests.  It makes auto_vec safe to use in >>>>>>> containers >>>>>>> that expect copyable and assignable element types and passes >>>>>>> bootstrap >>>>>>> and regression testing on x86_64-linux. >>>>>> >>>>>> The question is whether we want such uses to appear since those >>>>>> can be quite inefficient?  Thus the option is to delete those >>>>>> operators? >>>>> >>>>> I would strongly prefer the generic vector class to have the >>>>> properties >>>>> expected of any other generic container: copyable and assignable.  If >>>>> we also want another vector type with this restriction I suggest to >>>>> add >>>>> another "noncopyable" type and make that property explicit in its >>>>> name. >>>>> I can submit one in a followup patch if you think we need one. >>>> >>>> I'm not sure (and not strictly against the copy and assign). >>>> Looking around >>>> I see that vec<> does not do deep copying.  Making auto_vec<> do it >>>> might be surprising (I added the move capability to match how vec<> >>>> is used - as "reference" to a vector) >>> >>> The vec base classes are special: they have no ctors at all (because >>> of their use in unions).  That's something we might have to live with >>> but it's not a model to follow in ordinary containers. >>> >>> The auto_vec class was introduced to fill the need for a conventional >>> sequence container with a ctor and dtor.  The missing copy ctor and >>> assignment operators were an oversight, not a deliberate feature. >>> This change fixes that oversight. >>> >>> The revised patch also adds a copy ctor/assignment to the auto_vec >>> primary template (that's also missing it).  In addition, it adds >>> a new class called auto_vec_ncopy that disables copying and >>> assignment as you prefer.  It also disables copying for >>> the auto_string_vec class. >>> >>> Martin >> >