public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: Replace memcpy with std::copy to avoid some g++ warnings on sparc
@ 2023-01-30 21:14 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2023-01-30 21:14 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=214d883794db819617ee60806e3dbeb3d5dab666

commit 214d883794db819617ee60806e3dbeb3d5dab666
Author: Mark Wielaard <mark@klomp.org>
Date:   Sun Jan 15 01:06:16 2023 +0100

    gdb: Replace memcpy with std::copy to avoid some g++ warnings on sparc
    
    For some reason g++ 12.2.1 on sparc produces spurious warnings for
    stringop-overread and restrict in fbsd-tdep.c for a memcpy call.
    Use std::copy to avoid the warnings:
    
    In function ‘void* memcpy(void*, const void*, size_t)’,
        inlined from ‘gdb::optional<std::vector<unsigned char, gdb::default_init_allocator<unsigned char, std::allocator<unsigned char> > > > fbsd_make_note_desc(target_object, uint32_t)’ at ../../binutils-gdb/gdb/fbsd-tdep.c:666:10:
    /usr/include/bits/string_fortified.h:29:33: error: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ specified bound 18446744073709551612 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
    
    In function ‘void* memcpy(void*, const void*, size_t)’,
        inlined from ‘gdb::optional<std::vector<unsigned char, gdb::default_init_allocator<unsigned char, std::allocator<unsigned char> > > > fbsd_make_note_desc(target_object, uint32_t)’ at ../../binutils-gdb/gdb/fbsd-tdep.c:673:10:
    /usr/include/bits/string_fortified.h:29:33: error: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 18446744073709551612 bytes at offsets 0 and 0 overlaps 9223372036854775801 bytes at offset -9223372036854775805 [-Werror=restrict]
    
    gdb/ChangeLog:
    
            * fbsd-tdep.c (fbsd_make_note_desc): Use std::copy instead
            of memcpy.

Diff:
---
 gdb/fbsd-tdep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 203390d9880..3a7cb9b14ea 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -663,7 +663,7 @@ fbsd_make_note_desc (enum target_object object, uint32_t structsize)
 
   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 (buf->begin (), buf->end (), desc.data () + sizeof (structsize));
   return desc;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-30 21:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-30 21:14 [binutils-gdb] gdb: Replace memcpy with std::copy to avoid some g++ warnings on sparc Mark Wielaard

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).