From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <palves@redhat.com>
Cc: Simon Marchi <simon.marchi@ericsson.com>,
gdb-patches@sourceware.org, arnez@linux.vnet.ibm.com
Subject: Re: [PATCH] Make dwarf_expr_piece::pieces an std::vector
Date: Thu, 14 Sep 2017 09:26:00 -0000 [thread overview]
Message-ID: <20733c26c93b710b8554c149c02d3fb3@polymtl.ca> (raw)
In-Reply-To: <83688181-eb4a-b2d6-f614-b011c6220cd3@redhat.com>
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<dwarf_expr_piece> &&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
next prev parent reply other threads:[~2017-09-14 9:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-14 8:17 Simon Marchi
2017-09-14 9:21 ` Pedro Alves
2017-09-14 9:26 ` Simon Marchi [this message]
2017-09-14 10:24 ` Pedro Alves
2017-09-14 13:58 ` Simon Marchi
2017-09-14 14:14 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20733c26c93b710b8554c149c02d3fb3@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=simon.marchi@ericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox