Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb: add constructor to gdb_user_regs
@ 2022-08-06  5:14 Enze Li via Gdb-patches
  2022-08-08  8:03 ` Tom de Vries via Gdb-patches
  0 siblings, 1 reply; 3+ messages in thread
From: Enze Li via Gdb-patches @ 2022-08-06  5:14 UTC (permalink / raw)
  To: gdb-patches; +Cc: enze.li

When building gdb with clang 14 and -std=gnu++11, I ran into:

  CXX    user-regs.o
user-regs.c:83:29: error: no matching constructor for initialization of 'struct gdb_user_regs'
static struct gdb_user_regs builtin_user_regs = {
                            ^                   ~
user-regs.c:58:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
struct gdb_user_regs
       ^
user-regs.c:58:8: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
user-regs.c:58:8: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 2 were provided
1 error generated.

The fundamental reason is that C++11 does not support this approach.
This patch adds a constructor to gdb_user_regs to avoid the build
failure.

Tested by rebuilding on x86_64-linux with clang 14 and gcc 12, with and
without -std=gnu++11.
---
 gdb/user-regs.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gdb/user-regs.c b/gdb/user-regs.c
index 4bc4685387f..a2012b84534 100644
--- a/gdb/user-regs.c
+++ b/gdb/user-regs.c
@@ -57,8 +57,16 @@ struct user_reg
 
 struct gdb_user_regs
 {
-  struct user_reg *first = nullptr;
-  struct user_reg **last = nullptr;
+  gdb_user_regs (struct user_reg *mfirst, struct user_reg **mlast)
+    : first (mfirst),
+      last (mlast)
+  {
+  }
+
+  gdb_user_regs () = default;
+
+  struct user_reg *first;
+  struct user_reg **last;
 };
 
 static void
-- 
2.37.1


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

end of thread, other threads:[~2022-08-08 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-06  5:14 [PATCH] gdb: add constructor to gdb_user_regs Enze Li via Gdb-patches
2022-08-08  8:03 ` Tom de Vries via Gdb-patches
2022-08-08 13:08   ` Enze Li via Gdb-patches

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