Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Cc: arnez@linux.vnet.ibm.com
Subject: Re: [PATCH] Make dwarf_expr_piece::pieces an std::vector
Date: Thu, 14 Sep 2017 09:21:00 -0000	[thread overview]
Message-ID: <83688181-eb4a-b2d6-f614-b011c6220cd3@redhat.com> (raw)
In-Reply-To: <1505376948-22860-1-git-send-email-simon.marchi@ericsson.com>

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.

Thanks,
Pedro Alves


  reply	other threads:[~2017-09-14  9:21 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 [this message]
2017-09-14  9:26   ` Simon Marchi
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=83688181-eb4a-b2d6-f614-b011c6220cd3@redhat.com \
    --to=palves@redhat.com \
    --cc=arnez@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --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