From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12403 invoked by alias); 14 Sep 2017 09:26:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 12394 invoked by uid 89); 14 Sep 2017 09:26:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Sep 2017 09:26:49 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v8E9Qgks016411 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Sep 2017 05:26:47 -0400 Received: by simark.ca (Postfix, from userid 112) id 809A21ECED; Thu, 14 Sep 2017 05:26:42 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id B95CA1E984; Thu, 14 Sep 2017 05:26:40 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 14 Sep 2017 09:26:00 -0000 From: Simon Marchi To: Pedro Alves Cc: Simon Marchi , gdb-patches@sourceware.org, arnez@linux.vnet.ibm.com Subject: Re: [PATCH] Make dwarf_expr_piece::pieces an std::vector In-Reply-To: <83688181-eb4a-b2d6-f614-b011c6220cd3@redhat.com> References: <1505376948-22860-1-git-send-email-simon.marchi@ericsson.com> <83688181-eb4a-b2d6-f614-b011c6220cd3@redhat.com> Message-ID: <20733c26c93b710b8554c149c02d3fb3@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 14 Sep 2017 09:26:42 +0000 X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00372.txt.bz2 On 2017-09-14 11:21, Pedro Alves wrote: > On 09/14/2017 09:15 AM, Simon Marchi wrote: > >> static struct piece_closure * >> allocate_piece_closure (struct dwarf2_per_cu_data *per_cu, >> - int n_pieces, struct dwarf_expr_piece *pieces, >> + const std::vector &&pieces, > > const rval reference looks odd -- you can't really move > the internal elements out of a const vector. I think ... > >> struct frame_info *frame) >> { >> - struct piece_closure *c = XCNEW (struct piece_closure); >> + struct piece_closure *c = new piece_closure; >> int i; >> >> c->refc = 1; >> c->per_cu = per_cu; >> - c->n_pieces = n_pieces; >> - c->pieces = XCNEWVEC (struct dwarf_expr_piece, n_pieces); >> + c->pieces = std::move (pieces); > > ... this isn't really moving, but actually copying, because > you'll end up calling 'std::vector(const std::vector &)', not > 'std::vector(std::vector &&)'. > > I wonder if there's ever a case for 'const T &&' parameters, > and if GCC could warn about them. At least in non-template > functions. Oops, I started with a const reference, before changing it to rvalue reference (and forgot to remove the const). Does the patch look good to you otherwise? Simon