* [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
* Re: [PATCH] gdb: add constructor to gdb_user_regs
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
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries via Gdb-patches @ 2022-08-08 8:03 UTC (permalink / raw)
To: Enze Li, gdb-patches; +Cc: enze.li
On 8/6/22 07:14, Enze Li via Gdb-patches wrote:
> 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.
>
Hi,
I ran into a similar problem with gcc 4.8 (I noticed a build failure
with centos @ builder.sourceware.org) and fixed it here (
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=411c7e044fa99089d3030f2c61525c4d415f7b45
).
My apologies that I didn't notice your patch.
Anyway, I hope that this fixes the problem for you as well. I've
managed to do a build using clang-13.0.0 (with --disable-werror) up to
the point of an AFAICT unrelated linker failure.
Thanks,
- Tom
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb: add constructor to gdb_user_regs
2022-08-08 8:03 ` Tom de Vries via Gdb-patches
@ 2022-08-08 13:08 ` Enze Li via Gdb-patches
0 siblings, 0 replies; 3+ messages in thread
From: Enze Li via Gdb-patches @ 2022-08-08 13:08 UTC (permalink / raw)
To: Tom de Vries, gdb-patches; +Cc: enze.li
Hi Tom,
On Mon, 2022-08-08 at 10:03 +0200, Tom de Vries wrote:
> > On 8/6/22 07:14, Enze Li via Gdb-patches wrote:
> > > > 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.
> > > >
> >
> > Hi,
> >
> > I ran into a similar problem with gcc 4.8 (I noticed a build
> > failure
> > with centos @ builder.sourceware.org) and fixed it here (
> > https://sourceware.org/git/?p=binutils-
> gdb.git;a=commit;h=411c7e044fa99089d3030f2c61525c4d415f7b45
> > ).
> >
> > My apologies that I didn't notice your patch.
It's okay, mine is just a proposed one.
> >
> > Anyway, I hope that this fixes the problem for you as well. I've
> > managed to do a build using clang-13.0.0 (with --disable-werror)
> > up>
> to
> > the point of an AFAICT unrelated linker failure.
> >
> > Thanks,
> > - Tom
With your patch applied, I have tested with clang 13, 14 and 15, and
they all built successfully. Thanks for doing this.
Thanks,
Enze
> >
> > > > 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
^ 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