public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Hannes Domani <ssbssa@yahoo.de>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	Simon Marchi <simark@simark.ca>, Sam James <sam@gentoo.org>,
	Tom Tromey <tom@tromey.com>, John Baldwin <jhb@freebsd.org>
Subject: Re: [PATCHv5] gdb: Replace memcpy with std::copy to avoid some g++ warnings on sparc
Date: Wed, 25 Jan 2023 22:20:59 +0100	[thread overview]
Message-ID: <20230125212059.GK11538@gnu.wildebeest.org> (raw)
In-Reply-To: <1405677081.2976403.1674648005737@mail.yahoo.com>

Hi Hannes,

On Wed, Jan 25, 2023 at 12:00:05PM +0000, Hannes Domani wrote:
>  Am Mittwoch, 25. Januar 2023 um 09:56:03 MEZ hat Mark Wielaard <mark@klomp.org> Folgendes geschrieben:
> 
> >   gdb::byte_vector desc (sizeof (structsize) + buf->size ());
> > -  memcpy (desc.data (), &structsize, sizeof (structsize));
> > -  memcpy (desc.data () + sizeof (structsize), buf->data (), buf->size ());
> > +  std::copy (&structsize, &structsize + sizeof (structsize), desc.data ());
> 
> structsize is of type uint32_t, so wouldn't that effectively copy 4*4 bytes, instead of just 4?
> 
> Shouldn't it rather look like this?:
> 
>   std::copy (&structsize, &structsize + 1, desc.data ());

Aha, yeah, std::copy acts on the whole elements of the input. Maybe
less confusing to just keep using memcpy here. It is only the second
memcpy that produces the issue on sparc. That also brings down the fix
to a simple oneliner. Will sent a v6.

Thanks,

Mark

      reply	other threads:[~2023-01-25 21:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-25  8:55 Mark Wielaard
2023-01-25 12:00 ` Hannes Domani
2023-01-25 21:20   ` Mark Wielaard [this message]

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=20230125212059.GK11538@gnu.wildebeest.org \
    --to=mark@klomp.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@freebsd.org \
    --cc=sam@gentoo.org \
    --cc=simark@simark.ca \
    --cc=ssbssa@yahoo.de \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).