public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH][gdb/build] Fix build with g++-4.8
Date: Sun, 26 Sep 2021 11:15:23 +0200	[thread overview]
Message-ID: <20210926091521.GA31054@delia> (raw)

Hi,

When building g++-4.8, we run into:
...
src/gdb/dwarf2/read.c:919:5: error: multiple fields in union \
  'partial_die_info::<anonymous union>' initialized
...

This is due to:
...
    union
    {
      struct
      {
       CORE_ADDR lowpc = 0;
       CORE_ADDR highpc = 0;
      };
      ULONGEST ranges_offset;
    };
...

The error looks incorrect, given that only one union member is initialized,
and does not reproduce with newer g++.

Nevertheless, work around this by moving the initialization to a constructor.

[ I considered just removing the initialization, with the idea that access
should be guarded by has_pc_info, but I ran into one failure in the testsuite,
for gdb.base/check-psymtab.exp due to add_partial_symbol using lowpc without
checking has_pc_info. ]

Tested on x86_64-linux.

Any comments?

Thanks,
- Tom

[gdb/build] Fix build with g++-4.8

---
 gdb/dwarf2/read.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index d2501c9dd56..00aa64dd0ab 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -920,8 +920,8 @@ struct partial_die_info : public allocate_on_obstack
       /* If HAS_PC_INFO, the PC range associated with this DIE.  */
       struct
       {
-	CORE_ADDR lowpc = 0;
-	CORE_ADDR highpc = 0;
+	CORE_ADDR lowpc;
+	CORE_ADDR highpc;
       };
       /* If HAS_RANGE_INFO, the ranges offset associated with this DIE.  */
       ULONGEST ranges_offset;
@@ -974,6 +974,10 @@ struct partial_die_info : public allocate_on_obstack
       is_dwz = 0;
       spec_is_dwz = 0;
       canonical_name = 0;
+      /* Don't set these using NSDMI (Non-static data member initialisation),
+	 because g++-4.8 will error out.  */
+      lowpc = 0;
+      highpc = 0;
     }
   };
 

             reply	other threads:[~2021-09-26  9:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26  9:15 Tom de Vries [this message]
2021-09-26 19:33 ` Simon Marchi
2021-09-27  9:29   ` Tom de Vries
2021-09-27 11:58     ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210926091521.GA31054@delia \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).