[PATCH] [gdb/build] Fix build breaker with -std=c++11

John Baldwin jhb@FreeBSD.org
Mon Aug 7 18:01:14 GMT 2023


On 8/7/23 10:15 AM, Tom de Vries via Gdb-patches wrote:
> On 8/7/23 16:35, Simon Marchi wrote:
>>
>>
>> On August 6, 2023 7:59:15 p.m. EDT, Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> wrote:
>>> When building with -std=c++11 I run into:
>>> ...
>>> gdb/dwarf2/cooked-index.c: In member function \
>>>    ‘void cooked_index::start_writing_index(dwarf2_per_bfd*)’:
>>> gdb/dwarf2/cooked-index.c:469:10: error: lambda capture initializers only \
>>>    available with -std=c++14 or -std=gnu++14 [-Werror]
>>>            ctx = std::move (ctx)] ()
>>>            ^~~
>>> ...
>>>
>>> Fix this by capturing a copy instead:
>>> ...
>>>      = gdb::thread_pool::g_thread_pool->post_task ([this, per_bfd, ctx] ()
>>> ...
>>>
>>> Tested on x86_64-linux.
>>>
>>> Reported-By: Tom Tromey <tom@tromey.com>
>>
>> When we encounter things like this, should we add some greppable TODO comment to record an actionable item for when we switch to a more recent C++ version?
> 
> Hi Simon,
> 
> thanks for the review.
> 
> Fine by me, added comment.

An alternative that is slightly more work but might be nicer long term would be
to #if on the C++ version, so for example:

#if __cplusplus >= 201402L
   = gdb::thread_pool::g_thread_pool->post_task ([this, per_bfd,
                                                 ctx = std::move (ctx)] ()
#else
   = gdb::thread_pool::g_thread_pool->post_task ([this, per_bfd, ctx]) ()
#endif

-- 
John Baldwin



More information about the Gdb-patches mailing list