[binutils-gdb] gdb/dwarf: fix build error with older gcc

Simon Marchi via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=07caff21f90c2f0c9b7b0e79b00b774be668594c

commit 07caff21f90c2f0c9b7b0e79b00b774be668594c
Author: Simon Marchi <[email protected]>
Date:   Sun Mar 15 20:12:22 2026 -0400

    gdb/dwarf: fix build error with older gcc
    
    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
    Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81767

Diff:
---
 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 31c44476d2c..e41f06890d7 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)
 	{
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.