Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
To: Enze Li <enze.li@hotmail.com>, gdb-patches@sourceware.org
Cc: enze.li@gmx.com
Subject: Re: [PATCH] gdb: add constructor to gdb_user_regs
Date: Mon, 8 Aug 2022 10:03:46 +0200	[thread overview]
Message-ID: <7fc69637-ecd5-01e5-0db1-32fb2117322f@suse.de> (raw)
In-Reply-To: <OS3P286MB2152464D640198E960FC78C4F0619@OS3P286MB2152.JPNP286.PROD.OUTLOOK.COM>

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

  reply	other threads:[~2022-08-08  8:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-06  5:14 Enze Li via Gdb-patches
2022-08-08  8:03 ` Tom de Vries via Gdb-patches [this message]
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=7fc69637-ecd5-01e5-0db1-32fb2117322f@suse.de \
    --to=gdb-patches@sourceware.org \
    --cc=enze.li@gmx.com \
    --cc=enze.li@hotmail.com \
    --cc=tdevries@suse.de \
    /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