https://gcc.gnu.org/g:8354a70739419dc9e48e3b5613112e3ce737d246

commit r17-608-g8354a70739419dc9e48e3b5613112e3ce737d246
Author: David Malcolm <[email protected]>
Date:   Tue May 19 15:04:26 2026 -0400

    analyzer: bulletproof binop_svalue::maybe_get_value_range_1 [PR124104]
    
    r16-7560-gf310e487e1a5f0 bulletproofed
    unaryop_svalue::maybe_get_value_range against sloppy use of types in the
    analyzer.
    
    Do the same for binary ops.
    
    gcc/analyzer/ChangeLog:
            PR analyzer/124104
            * svalue.cc (binop_svalue::maybe_get_value_range_1): Bail out for
            incompatible types.
    
    Signed-off-by: David Malcolm <[email protected]>

Diff:
---
 gcc/analyzer/svalue.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc
index 1c0041ab75bb..2df7627dd30d 100644
--- a/gcc/analyzer/svalue.cc
+++ b/gcc/analyzer/svalue.cc
@@ -1748,7 +1748,8 @@ binop_svalue::maybe_get_value_range_1 (value_range &out) 
const
     if (m_arg1->maybe_get_value_range (rhs))
       {
        range_op_handler handler (m_op);
-       if (handler)
+       if (handler
+           && handler.operand_check_p (type, lhs.type (), rhs.type ()))
          {
            out.set_range_class (type);
            if (handler.fold_range (out, get_type (), lhs, rhs))

Reply via email to