From: Kevin Buettner <kevinb@redhat.com>
To: John Baldwin <jhb@FreeBSD.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: fix ppc-sysv-tdep.c build on 32-bit platforms
Date: Fri, 28 Jan 2022 13:20:15 -0700 [thread overview]
Message-ID: <20220128132015.3c8ff023@f35-zws-1> (raw)
In-Reply-To: <20220128192425.76123-1-jhb@FreeBSD.org>
Hi John,
LGTM.
Kevin
On Fri, 28 Jan 2022 11:24:25 -0800
John Baldwin <jhb@FreeBSD.org> wrote:
> The previous code triggered the following error on an i386 host:
>
> /git/gdb/gdb/ppc-sysv-tdep.c:1764:34: error: non-constant-expression cannot be narrowed from type 'ULONGEST' (aka 'unsigned long long') to 'size_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
> unscaled.read ({writebuf, TYPE_LENGTH (valtype)},
> ^~~~~~~~~~~~~~~~~~~~~
> /git/gdb/gdb/gdbtypes.h:2043:31: note: expanded from macro 'TYPE_LENGTH'
> ^~~~~~~~~~~~~~~~~~
> /git/gdb/gdb/ppc-sysv-tdep.c:1764:34: note: insert an explicit cast to silence this issue
> unscaled.read ({writebuf, TYPE_LENGTH (valtype)},
> ^~~~~~~~~~~~~~~~~~~~~
> static_cast<size_t>( )
> /git/gdb/gdb/gdbtypes.h:2043:31: note: expanded from macro 'TYPE_LENGTH'
> ^~~~~~~~~~~~~~~~~~
> 1 error generated.
>
> Fix this by using gdb::make_array_view.
> ---
> gdb/ppc-sysv-tdep.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
> index 5255cea43e3..9a3b02f028d 100644
> --- a/gdb/ppc-sysv-tdep.c
> +++ b/gdb/ppc-sysv-tdep.c
> @@ -1761,7 +1761,8 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype,
> /* Fixed point type values need to be returned unscaled. */
> gdb_mpz unscaled;
>
> - unscaled.read ({writebuf, TYPE_LENGTH (valtype)},
> + unscaled.read (gdb::make_array_view (writebuf,
> + TYPE_LENGTH (valtype)),
> type_byte_order (valtype),
> valtype->is_unsigned ());
> return_val = unscaled.as_integer<LONGEST> ();
> --
> 2.34.1
>
prev parent reply other threads:[~2022-01-28 20:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 19:24 John Baldwin
2022-01-28 20:19 ` Tom Tromey
2022-01-28 20:20 ` Kevin Buettner [this message]
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=20220128132015.3c8ff023@f35-zws-1 \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jhb@FreeBSD.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).