From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id DBAAC3894C38 for ; Tue, 27 Apr 2021 14:05:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DBAAC3894C38 Received: by mail-ed1-x52d.google.com with SMTP id i24so10507236edy.8 for ; Tue, 27 Apr 2021 07:05:03 -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:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yfazJIXD+dWOC4CXd/fUZcbnEsxhjmdZ84GxyOulEFI=; b=H+g/J2xo7qGAReyHO+A2qL5Zsc00XeufU9LiHSxlwJcOZNhm0BFlJ8tkLPxQfvs/T+ 3KJUv9IsUQsmcabdBUDMOnQgOJY9Vy4n/GmSH6tDxVIf0jpLYub5kHaN45HiBnF0kT2J 7eh0NAW9SMMueVJqbR2xVM7nFYw0JSkISidHmLzB4WA3G5EbAqP87dfXJutyCSsgIVGp cBp1VJwe6/8lPXlhk4JJRWx28rY4Au+k+31Ip0oSu4Lq1V2V755+LS09nsdrNVYKl8Zk hmkXZZHF63oECrNv32R4JVTOVbWIoTY2SIVEa7HI9lg1fMIPPlYm3UKV4XL5lIhKbzIr BItg== X-Gm-Message-State: AOAM531cfgyw5RceUSX1kubzSvE/sep3iHbD/p/Qh7LEpZC9QT3MMtvd HepMShenR7juZV1o/zfaUNr2cdYHtRtvOZsmQdw= X-Google-Smtp-Source: ABdhPJycguffhwsxGDXbaSq4M+k+GTH4CWnuwxMDpsxcI1crnbrK87TPxAT51KJiCDRCjGTfxZg+0HBPMN51FBEr0tg= X-Received: by 2002:aa7:c44b:: with SMTP id n11mr3007410edr.214.1619532302958; Tue, 27 Apr 2021 07:05:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Tue, 27 Apr 2021 16:04:52 +0200 Message-ID: Subject: Re: [PATCH] define auto_vec copy ctor and assignment (PR 90904) To: Martin Sebor Cc: gcc-patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: Tue, 27 Apr 2021 14:05:06 -0000 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) Richard. > Martin