From 400abebf48a90d0797718ab7c3864de331e85b70 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 17 Aug 2020 21:12:35 -0400 Subject: analyzer: fix ICE with negative bit offsets [PR96648] PR analyzer/96648 reports an ICE within get_field_at_bit_offset due to a negative bit offset, arising due to pointer arithmetic. This patch replaces an assertion with handling for this case, fixing the ICE. gcc/analyzer/ChangeLog: PR analyzer/96648 * region.cc (get_field_at_bit_offset): Gracefully handle negative values for bit_offset. gcc/testsuite/ChangeLog: PR analyzer/96648 * gcc.dg/analyzer/pr96648.c: New test. --- gcc/analyzer/region.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/analyzer') diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc index eab1f27..770e2cb 100644 --- a/gcc/analyzer/region.cc +++ b/gcc/analyzer/region.cc @@ -226,7 +226,8 @@ static tree get_field_at_bit_offset (tree record_type, bit_offset_t bit_offset) { gcc_assert (TREE_CODE (record_type) == RECORD_TYPE); - gcc_assert (bit_offset >= 0); + if (bit_offset < 0) + return NULL; /* Find the first field that has an offset > BIT_OFFSET, then return the one preceding it. -- cgit v1.1