Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/dwarf: fix build error with older gcc
@ 2026-03-16  0:18 simon.marchi
  2026-03-16  0:22 ` Andrew Pinski
  0 siblings, 1 reply; 3+ messages in thread
From: simon.marchi @ 2026-03-16  0:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@polymtl.ca>

With gcc 7.5.0, we get:

      CXX    dwarf2/read.o
    /home/simark/src/binutils-gdb/gdb/dwarf2/read.c: In function ‘void decode_line_header_for_cu(die_info*, dwarf2_cu*, const file_and_directory&)’:
    /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:5796:25: error: unused variable ‘_’ [-Werror=unused-variable]
           auto [_, inserted_]
                             ^

That version of gcc (and earlier) apparently produces unused variable
warnings for unused structured bindings.  Fix it by accessing `.second`
directly to get the "inserted" boolean value.

Change-Id: I6e78c8c317623f3d830fef8d043f85ff789133d4
---
 gdb/dwarf2/read.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 31c44476d2ca..e41f06890d74 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -5793,9 +5793,8 @@ decode_line_header_for_cu (struct die_info *die, struct dwarf2_cu *cu,
 
   if (per_objfile->line_headers.has_value ())
     {
-      auto [_, inserted_]
-	= per_objfile->line_headers->try_emplace (sao, cu->line_header);
-      inserted = inserted_;
+      inserted
+	= per_objfile->line_headers->try_emplace (sao, cu->line_header).second;
 
       if (inserted)
 	{

base-commit: 7def0c077dc47cefa252f0c8df08f9b986b26306
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb/dwarf: fix build error with older gcc
  2026-03-16  0:18 [PATCH] gdb/dwarf: fix build error with older gcc simon.marchi
@ 2026-03-16  0:22 ` Andrew Pinski
  2026-03-16  0:24   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Pinski @ 2026-03-16  0:22 UTC (permalink / raw)
  To: simon.marchi; +Cc: gdb-patches

On Sun, Mar 15, 2026 at 5:20 PM <simon.marchi@polymtl.ca> wrote:
>
> From: Simon Marchi <simon.marchi@polymtl.ca>
>
> With gcc 7.5.0, we get:
>
>       CXX    dwarf2/read.o
>     /home/simark/src/binutils-gdb/gdb/dwarf2/read.c: In function ‘void decode_line_header_for_cu(die_info*, dwarf2_cu*, const file_and_directory&)’:
>     /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:5796:25: error: unused variable ‘_’ [-Werror=unused-variable]
>            auto [_, inserted_]
>                              ^
>
> That version of gcc (and earlier) apparently produces unused variable
> warnings for unused structured bindings.  Fix it by accessing `.second`
> directly to get the "inserted" boolean value.

LGTM but it might be useful to reference the GCC bug report that I mentioned
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81767) in the commit too.

Thanks,
Andrew Pinski


>
> Change-Id: I6e78c8c317623f3d830fef8d043f85ff789133d4
> ---
>  gdb/dwarf2/read.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 31c44476d2ca..e41f06890d74 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -5793,9 +5793,8 @@ decode_line_header_for_cu (struct die_info *die, struct dwarf2_cu *cu,
>
>    if (per_objfile->line_headers.has_value ())
>      {
> -      auto [_, inserted_]
> -       = per_objfile->line_headers->try_emplace (sao, cu->line_header);
> -      inserted = inserted_;
> +      inserted
> +       = per_objfile->line_headers->try_emplace (sao, cu->line_header).second;
>
>        if (inserted)
>         {
>
> base-commit: 7def0c077dc47cefa252f0c8df08f9b986b26306
> --
> 2.53.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gdb/dwarf: fix build error with older gcc
  2026-03-16  0:22 ` Andrew Pinski
@ 2026-03-16  0:24   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2026-03-16  0:24 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gdb-patches



On 2026-03-15 20:22, Andrew Pinski wrote:
> On Sun, Mar 15, 2026 at 5:20 PM <simon.marchi@polymtl.ca> wrote:
>>
>> From: Simon Marchi <simon.marchi@polymtl.ca>
>>
>> With gcc 7.5.0, we get:
>>
>>       CXX    dwarf2/read.o
>>     /home/simark/src/binutils-gdb/gdb/dwarf2/read.c: In function ‘void decode_line_header_for_cu(die_info*, dwarf2_cu*, const file_and_directory&)’:
>>     /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:5796:25: error: unused variable ‘_’ [-Werror=unused-variable]
>>            auto [_, inserted_]
>>                              ^
>>
>> That version of gcc (and earlier) apparently produces unused variable
>> warnings for unused structured bindings.  Fix it by accessing `.second`
>> directly to get the "inserted" boolean value.
> 
> LGTM but it might be useful to reference the GCC bug report that I mentioned
> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81767) in the commit too.
> 
> Thanks,
> Andrew Pinski

Ok thanks, will add a:

Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81767

I will push it right away, I think it's simple enough.

Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-16  0:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-16  0:18 [PATCH] gdb/dwarf: fix build error with older gcc simon.marchi
2026-03-16  0:22 ` Andrew Pinski
2026-03-16  0:24   ` Simon Marchi

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