Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [pushed] gdb/record-full: fix some -Wpessimizing-move errors
@ 2026-07-06 14:43 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2026-07-06 14:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Compiling record-full.c with clang shows:

    /home/smarchi/src/binutils-gdb/gdb/record-full.c:2386:14: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
     2386 |         rec.entry = std::move (record_full_reg_entry::from_bfd
          |                     ^
    /home/smarchi/src/binutils-gdb/gdb/record-full.c:2386:14: note: remove std::move call here
     2386 |         rec.entry = std::move (record_full_reg_entry::from_bfd
          |                     ^~~~~~~~~~~
     2387 |                                 (cbfd, osec, bfd_offset));
          |                                                         ~
    /home/smarchi/src/binutils-gdb/gdb/record-full.c:2393:14: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
     2393 |         rec.entry = std::move (record_full_mem_entry::from_bfd
          |                     ^
    /home/smarchi/src/binutils-gdb/gdb/record-full.c:2393:14: note: remove std::move call here
     2393 |         rec.entry = std::move (record_full_mem_entry::from_bfd
          |                     ^~~~~~~~~~~
     2394 |                                 (cbfd, osec, bfd_offset));
          |                                                         ~

It's indeed not recommended to std::move the return value of a
function.  Remove the std::moves.

Change-Id: I80d947aa3d917fe3fcaaad0c3e329cb1de48a8ee
---
 gdb/record-full.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gdb/record-full.c b/gdb/record-full.c
index 695d9d1622cd..1392510a175c 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -2383,15 +2383,13 @@ record_full_entry::from_bfd (bfd *cbfd, asection *osec, int *bfd_offset)
     {
     case record_full_reg: /* reg */
       {
-	rec.entry = std::move (record_full_reg_entry::from_bfd
-				(cbfd, osec, bfd_offset));
+	rec.entry = record_full_reg_entry::from_bfd (cbfd, osec, bfd_offset);
 	break;
       }
 
     case record_full_mem: /* mem */
       {
-	rec.entry = std::move (record_full_mem_entry::from_bfd
-				(cbfd, osec, bfd_offset));
+	rec.entry = record_full_mem_entry::from_bfd (cbfd, osec, bfd_offset);
 	break;
       }
 

base-commit: 748bc6a7febf874d84657f538c9d9e3b8153c6e7
-- 
2.55.0


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

only message in thread, other threads:[~2026-07-06 14:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-06 14:43 [pushed] gdb/record-full: fix some -Wpessimizing-move errors Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox