From 7a6f3e7e39701b2b0e2f3b8f761e7c32f46af4a6 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Tue, 8 Aug 2023 01:34:45 +0200 Subject: [PATCH] [gdb/build] Use move capture in gdb_demangle Use move capture in gdb_demangle when compiling for c++14 or higher, to save a std::string copy. Tested on x86_64-linux. Reported-By: Tom Tromey --- gdb/cp-support.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 2fb9d9ef0b2..0300727434d 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1656,7 +1656,13 @@ gdb_demangle (const char *name, int options) we might be in a background thread. Instead, arrange for the reporting to happen on the main thread. */ std::string copy = name; - run_on_main_thread ([=] () + run_on_main_thread ([ +#if __cplusplus >= 201402L + =, copy = std::move (copy) +#else + = +#endif + ] () { report_failed_demangle (copy.c_str (), core_dump_allowed, crash_signal); base-commit: ddbe8c3c8a8665e77f9ebb108c5627a6ebecb81f -- 2.35.3