From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by sourceware.org (Postfix) with ESMTPS id 0ADA23992421 for ; Tue, 27 Apr 2021 13:59:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0ADA23992421 Received: by mail-qk1-x730.google.com with SMTP id 190so3318938qkl.11 for ; Tue, 27 Apr 2021 06:59:02 -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=Rla9ZzY5s85ThhoAccTt8dmMLeAsF7DF/8imhY5Qa6I=; b=k/skQk+zfS4HrOnQF/7WXm7NVaM2K3P9EEJuIFM7QMcBocILOuaLQ5wbSJ59+Ah/c1 i+8Fs/wHRL/Osn0bda5DLgIYj21yP6FdpS8S4UVjSuu0n/N+Ut9bnaN7a2IQdpzsvO03 g/mR6/VG/DgQWIJdZ5z9F7hTG8g7z7alhwoAnSQ3BtODrckfa0nibjId4XQR+qq1we9x akNr0I0/0xijYpiMeeNNrBzALVmc7aUJsrFFfn5e6hhSdHtn/vKfpoXpsgTPRgovsmC8 /yHdvtXNBR4bLwYFjoWTDN3dhO/nLy2yN4IThOSeKX4TKOgy88khmyLev2fcuywpaZj5 0+Gg== X-Gm-Message-State: AOAM5323ETjSwghreabtj4G2sq0QTNdpEdgOOrDIrD40JGAQPQz1jdbC /dNsFRR2Vb/A2hTBxohkcwB8qWcsBVs= X-Google-Smtp-Source: ABdhPJybcfb80HtKO9HAh+g752WMJ0gM0PxBjVmT/fFENdRWBYeGYXcr6o6SL55FLw5e1ypXEPrRVA== X-Received: by 2002:a37:a053:: with SMTP id j80mr11452381qke.443.1619531941460; Tue, 27 Apr 2021 06:59:01 -0700 (PDT) Received: from [192.168.0.41] (71-218-14-121.hlrn.qwest.net. [71.218.14.121]) by smtp.gmail.com with ESMTPSA id a10sm14073735qtm.16.2021.04.27.06.59.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Apr 2021 06:59:01 -0700 (PDT) Subject: Re: [PATCH] define auto_vec copy ctor and assignment (PR 90904) To: Richard Biener Cc: gcc-patches References: From: Martin Sebor Message-ID: Date: Tue, 27 Apr 2021 07:58:59 -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: 7bit 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.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 13:59:03 -0000 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. Martin