From aba4e7763c127ddcdbb37d6eed2f77faae85e71d Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 27 May 2020 18:36:11 -0400 Subject: [PATCH 188/315] FIXME: handle negative offsets in calc_offset --- gcc/analyzer/region-model2.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/analyzer/region-model2.cc b/gcc/analyzer/region-model2.cc index fff49c3dc06..f786f7bd386 100644 --- a/gcc/analyzer/region-model2.cc +++ b/gcc/analyzer/region-model2.cc @@ -1070,8 +1070,11 @@ region2::calc_offset () const = offset_region->get_byte_offset ()->maybe_get_constant ()) { gcc_assert (TREE_CODE (byte_offset_cst) == INTEGER_CST); - offset_int byte_offset = wi::to_offset (byte_offset_cst); - offset_int bit_offset = byte_offset << LOG2_BITS_PER_UNIT; + /* Use a signed value for the byte offset, to handle + negative offsets. */ + HOST_WIDE_INT byte_offset + = wi::to_offset (byte_offset_cst).to_shwi (); + HOST_WIDE_INT bit_offset = byte_offset * BITS_PER_UNIT; accum_bit_offset += bit_offset; } else -- 2.26.2