https://gcc.gnu.org/g:158695695bf458a3f95be2177aa1320574d6848f
commit r17-6300-g158695695bf458a3f95be2177aa1320574d6848f Author: David Malcolm <[email protected]> Date: Sun Nov 15 14:32:20 2026 -0500 analyzer: add assertion to svalue_from_bit_vector ctor gcc/analyzer/ChangeLog: * svalue.cc (svalue_from_bit_vector::svalue_from_bit_vector): Assert that all-zeros/all-ones of integral type have been folded to constant. * svalue.h (class svalue_from_bit_vector): Update leading comment. Signed-off-by: David Malcolm <[email protected]> Diff: --- gcc/analyzer/svalue.cc | 5 +++++ gcc/analyzer/svalue.h | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index abb16bce1cfd..97cb93a6b44a 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -1662,6 +1662,11 @@ svalue_from_bit_vector (symbolic::node::id_t id, // No nesting: gcc_assert (!m_bv.dyn_cast_bit_vector_from_svalue ()); + + // All-zeros/all-ones of integral type should have been folded to constant + if (auto *tristate_bv = m_bv.dyn_cast_tristate_bit_vector ()) + if (type && INTEGRAL_TYPE_P (type)) + gcc_assert (tristate_bv->get_bit_value () == tristate::unknown ()); } } diff --git a/gcc/analyzer/svalue.h b/gcc/analyzer/svalue.h index 7af9025f12cf..b8a8b15c0816 100644 --- a/gcc/analyzer/svalue.h +++ b/gcc/analyzer/svalue.h @@ -831,7 +831,10 @@ namespace ana { - all qualifiers (except address spaces) are stripped from the type of the pointee - no nesting: the underlying bit vector can't be a bit_vector_from_svalue - (we fold away such cases). */ + (we fold away such cases). + - for integral types, the underlying bit_vector must not be a + tristate_bit_vector of kind "true" or "false" (but could be "unknown"): + all-zeros/all-ones get folded to constant_svalue. */ class svalue_from_bit_vector : public svalue {
