aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/store.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2023-12-07 19:42:45 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2023-12-07 19:42:45 -0500
commit775aeabcb870b74e4d0986341c7a39add9bbb06d (patch)
treedc7678c952305a946b2bd5675b5f4399d8686856 /gcc/analyzer/store.h
parent08f89e5e7f466cf18387293c6a9d1d5b8308b83d (diff)
downloadgcc-775aeabcb870b74e4d0986341c7a39add9bbb06d.zip
gcc-775aeabcb870b74e4d0986341c7a39add9bbb06d.tar.gz
gcc-775aeabcb870b74e4d0986341c7a39add9bbb06d.tar.bz2
analyzer: fix ICE for 2 bits before the start of base region [PR112889]
Cncrete bindings were using -1 and -2 in the offset field to signify deleted and empty hash slots, but these are valid values, leading to assertion failures inside hash_map::put on a debug build, and probable bugs in a release build. (gdb) call k.dump(true) start: -2, size: 1, next: -1 (gdb) p k.is_empty() $6 = true Fix by using the size field rather than the offset. gcc/analyzer/ChangeLog: PR analyzer/112889 * store.h (concrete_binding::concrete_binding): Strengthen assertion to require size to be be positive, rather than just non-zero. (concrete_binding::mark_deleted): Use size rather than start bit offset. (concrete_binding::mark_empty): Likewise. (concrete_binding::is_deleted): Likewise. (concrete_binding::is_empty): Likewise. gcc/testsuite/ChangeLog: PR analyzer/112889 * c-c++-common/analyzer/ice-pr112889.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer/store.h')
-rw-r--r--gcc/analyzer/store.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/gcc/analyzer/store.h b/gcc/analyzer/store.h
index cf10fa3..d75d69d 100644
--- a/gcc/analyzer/store.h
+++ b/gcc/analyzer/store.h
@@ -377,7 +377,7 @@ public:
concrete_binding (bit_offset_t start_bit_offset, bit_size_t size_in_bits)
: m_bit_range (start_bit_offset, size_in_bits)
{
- gcc_assert (!m_bit_range.empty_p ());
+ gcc_assert (m_bit_range.m_size_in_bits > 0);
}
bool concrete_p () const final override { return true; }
@@ -419,10 +419,10 @@ public:
static int cmp_ptr_ptr (const void *, const void *);
- void mark_deleted () { m_bit_range.m_start_bit_offset = -1; }
- void mark_empty () { m_bit_range.m_start_bit_offset = -2; }
- bool is_deleted () const { return m_bit_range.m_start_bit_offset == -1; }
- bool is_empty () const { return m_bit_range.m_start_bit_offset == -2; }
+ void mark_deleted () { m_bit_range.m_size_in_bits = -1; }
+ void mark_empty () { m_bit_range.m_size_in_bits = -2; }
+ bool is_deleted () const { return m_bit_range.m_size_in_bits == -1; }
+ bool is_empty () const { return m_bit_range.m_size_in_bits == -2; }
private:
bit_range m_bit_range;