From: Enze Li via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: enze.li@gmx.com
Subject: [PATCH] gdb: add constructor to gdb_user_regs
Date: Sat, 6 Aug 2022 13:14:13 +0800 [thread overview]
Message-ID: <OS3P286MB2152464D640198E960FC78C4F0619@OS3P286MB2152.JPNP286.PROD.OUTLOOK.COM> (raw)
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
next reply other threads:[~2022-08-06 5:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-06 5:14 Enze Li via Gdb-patches [this message]
2022-08-08 8:03 ` Tom de Vries via Gdb-patches
2022-08-08 13:08 ` Enze Li via Gdb-patches
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=OS3P286MB2152464D640198E960FC78C4F0619@OS3P286MB2152.JPNP286.PROD.OUTLOOK.COM \
--to=gdb-patches@sourceware.org \
--cc=enze.li@gmx.com \
--cc=enze.li@hotmail.com \
/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