From: John Baldwin Date: Fri, 28 Jan 2022 19:22:02 +0000 (-0800) Subject: gdb: fix ppc-sysv-tdep.c build on 32-bit platforms X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e5783467a342ffdc89cc7fb678eae033c2f7cce1;p=binutils-gdb.git gdb: fix ppc-sysv-tdep.c build on 32-bit platforms 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( ) /git/gdb/gdb/gdbtypes.h:2043:31: note: expanded from macro 'TYPE_LENGTH' ^~~~~~~~~~~~~~~~~~ 1 error generated. Fix this by using gdb::make_array_view. --- 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 ();