public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH] gdb/dwarf2/read.c: remove pessimizing std::move
Date: Mon, 22 Apr 2024 15:01:37 -0400	[thread overview]
Message-ID: <20240422190139.36506-1-simon.marchi@efficios.com> (raw)

When building with this clang:

    $ c++ --version
    FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)

I see:

    $ gmake
      CXX    dwarf2/read.o
    /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:4890:6: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
                                            std::move (thread_storage.release_parent_map ()));
                                            ^
    /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:4890:6: note: remove std::move call here
                                            std::move (thread_storage.release_parent_map ()));
                                            ^~~~~~~~~~~                                    ~

The compiler seems right, there is not need to std::move the result of
`release_parent_map ()`, it's already going to be an rvalue.  Remove the
std::move.

The issue isn't FreeBSD-specific, I see it on Linux as well when
building hwith clang, I just noticed it on a FreeBSD build first.

Change-Id: I7aa20a4db56c799f20d838ad08099a01653bba19
---
 gdb/dwarf2/read.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index af69e1d9d9e9..96e51bb42b0f 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -4885,7 +4885,7 @@ cooked_index_debug_info::process_cus (size_t task_number, unit_iterator first,
   m_results[task_number] = result_type (thread_storage.release (),
 					complaint_handler.release (),
 					std::move (errors),
-					std::move (thread_storage.release_parent_map ()));
+					thread_storage.release_parent_map ());
 }
 
 void

base-commit: fdaa4939e5024ea809c0d4d1aa6043a60b37d9b5
-- 
2.44.0


             reply	other threads:[~2024-04-22 19:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 19:01 Simon Marchi [this message]
2024-04-23 14:39 ` Tom Tromey
2024-04-23 14:40   ` Simon Marchi

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=20240422190139.36506-1-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /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).