* [PATCH v2] gdb: fix build errors in gdbsupport/thread-pool.h used with old gcc
@ 2022-04-14 2:45 Tiezhu Yang
2022-04-14 5:06 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Tiezhu Yang @ 2022-04-14 2:45 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey, Simon Marchi
When I build gdb with gcc 8.3, there exist the following build errors,
rename the typedef to task_t to fix them.
CXX thread-pool.o
In file included from /home/loongson/gdb.git/gdbsupport/thread-pool.cc:21:
/home/loongson/gdb.git/gdbsupport/../gdbsupport/thread-pool.h: In member function ‘std::future<void> gdb::thread_pool::post_task(std::function<void()>&&)’:
/home/loongson/gdb.git/gdbsupport/../gdbsupport/thread-pool.h:69:44: error: declaration of ‘task’ shadows a previous local [-Werror=shadow=local]
std::packaged_task<void ()> task (std::move (func));
^~~~
/home/loongson/gdb.git/gdbsupport/../gdbsupport/thread-pool.h:102:39: note: shadowed declaration is here
typedef std::packaged_task<void ()> task;
^~~~
/home/loongson/gdb.git/gdbsupport/../gdbsupport/thread-pool.h: In member function ‘std::future<_Res> gdb::thread_pool::post_task(std::function<T()>&&)’:
/home/loongson/gdb.git/gdbsupport/../gdbsupport/thread-pool.h:80:41: error: declaration of ‘task’ shadows a previous local [-Werror=shadow=local]
std::packaged_task<T ()> task (std::move (func));
^~~~
/home/loongson/gdb.git/gdbsupport/../gdbsupport/thread-pool.h:102:39: note: shadowed declaration is here
typedef std::packaged_task<void ()> task;
^~~~
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
gdbsupport/thread-pool.cc | 2 +-
gdbsupport/thread-pool.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdbsupport/thread-pool.cc b/gdbsupport/thread-pool.cc
index efd8b79..464e32f 100644
--- a/gdbsupport/thread-pool.cc
+++ b/gdbsupport/thread-pool.cc
@@ -171,7 +171,7 @@ thread_pool::thread_function ()
while (true)
{
- optional<task> t;
+ optional<task_t> t;
{
/* We want to hold the lock while examining the task list, but
diff --git a/gdbsupport/thread-pool.h b/gdbsupport/thread-pool.h
index 3243346..5e203fd 100644
--- a/gdbsupport/thread-pool.h
+++ b/gdbsupport/thread-pool.h
@@ -99,13 +99,13 @@ class thread_pool
size_t m_thread_count = 0;
/* A convenience typedef for the type of a task. */
- typedef std::packaged_task<void ()> task;
+ typedef std::packaged_task<void ()> task_t;
/* The tasks that have not been processed yet. An optional is used
to represent a task. If the optional is empty, then this means
that the receiving thread should terminate. If the optional is
non-empty, then it is an actual task to evaluate. */
- std::queue<optional<task>> m_tasks;
+ std::queue<optional<task_t>> m_tasks;
/* A condition variable and mutex that are used for communication
between the main thread and the worker threads. */
--
2.1.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] gdb: fix build errors in gdbsupport/thread-pool.h used with old gcc
2022-04-14 2:45 [PATCH v2] gdb: fix build errors in gdbsupport/thread-pool.h used with old gcc Tiezhu Yang
@ 2022-04-14 5:06 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2022-04-14 5:06 UTC (permalink / raw)
To: Tiezhu Yang; +Cc: gdb-patches, Tom Tromey, Simon Marchi
>>>>> Tiezhu Yang <yangtiezhu@loongson.cn> writes:
> When I build gdb with gcc 8.3, there exist the following build errors,
> rename the typedef to task_t to fix them.
Thank you for the patch. This looks good, please check it in.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-14 5:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 2:45 [PATCH v2] gdb: fix build errors in gdbsupport/thread-pool.h used with old gcc Tiezhu Yang
2022-04-14 5:06 ` Tom Tromey
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).