From 5612b5d21e41796c9d6fb024c4bbf70719153373 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 27 Oct 2021 09:38:51 -0400 Subject: [PATCH] gdb: fix value.c build on 32-bits When building on ARM (32-bits), we errors like this: /home/smarchi/src/binutils-gdb/gdb/value.c: In function 'gdb::array_view value_contents_for_printing(value*)': /home/smarchi/src/binutils-gdb/gdb/value.c:1252:35: error: narrowing conversion of 'length' from 'ULONGEST' {aka 'long long unsigned int'} to 'size_t' {aka 'unsigned int'} [-Werror=narrowing] 1252 | return {value->contents.get (), length}; | ^~~~~~ Fix that by using gdb::make_array_view, which does the appropriate conversion. Change-Id: I7d6f2e75d7440d248b8fb18f8272ee92954b404d --- gdb/value.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/value.c b/gdb/value.c index 42ce80416f1..a0ce3a796d0 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1155,7 +1155,8 @@ value_contents_raw (struct value *value) allocate_value_contents (value); ULONGEST length = TYPE_LENGTH (value_type (value)); - return {value->contents.get () + value->embedded_offset * unit_size, length}; + return gdb::make_array_view + (value->contents.get () + value->embedded_offset * unit_size, length); } gdb::array_view @@ -1164,7 +1165,7 @@ value_contents_all_raw (struct value *value) allocate_value_contents (value); ULONGEST length = TYPE_LENGTH (value_type (value)); - return {value->contents.get (), length}; + return gdb::make_array_view (value->contents.get (), length); } struct type * @@ -1249,7 +1250,7 @@ value_contents_for_printing (struct value *value) value_fetch_lazy (value); ULONGEST length = TYPE_LENGTH (value_type (value)); - return {value->contents.get (), length}; + return gdb::make_array_view (value->contents.get (), length); } gdb::array_view @@ -1258,7 +1259,7 @@ value_contents_for_printing_const (const struct value *value) gdb_assert (!value->lazy); ULONGEST length = TYPE_LENGTH (value_type (value)); - return {value->contents.get (), length}; + return gdb::make_array_view (value->contents.get (), length); } gdb::array_view -- 2.30.2