@@ -2009,7 +2009,8 @@ void CheckConditionImpl::checkCompareValueOutOfTypeRange()
20092009 for (int i = 0 ; i < 2 ; ++i) {
20102010 const Token * const valueTok = (i == 0 ) ? tok->astOperand1 () : tok->astOperand2 ();
20112011 const Token * const typeTok = valueTok->astSibling ();
2012- if (!valueTok->hasKnownIntValue () || !typeTok->valueType () || typeTok->valueType ()->pointer )
2012+ const ValueType* const typeVt = typeTok->valueType ();
2013+ if (!valueTok->hasKnownIntValue () || !typeVt || typeVt->pointer )
20132014 continue ;
20142015 if (valueTok->getKnownIntValue () < 0 && valueTok->valueType () && valueTok->valueType ()->sign != ValueType::Sign::SIGNED )
20152016 continue ;
@@ -2040,11 +2041,11 @@ void CheckConditionImpl::checkCompareValueOutOfTypeRange()
20402041 }
20412042 if (bits == 0 || bits >= 63 )
20422043 continue ;
2043-
2044- const auto typeMinValue = (typeTok-> valueType () ->sign == ValueType::Sign::UNSIGNED ) ? 0 : (-(1LL << (bits-1 )));
2044+
2045+ const auto typeMinValue = (typeVt ->sign == ValueType::Sign::UNSIGNED ) ? 0 : (-(1LL << (bits-1 )));
20452046 const auto unsignedTypeMaxValue = (1LL << bits) - 1LL ;
2046- long long typeMaxValue;
2047- if (typeTok-> valueType () ->sign != ValueType::Sign::SIGNED )
2047+ long long typeMaxValue;
2048+ if (typeVt-> sign != ValueType::Sign:: SIGNED && !(typeVt ->sign == ValueType::Sign::UNKNOWN_SIGN && typeVt-> type == ValueType::Type:: CHAR && mSettings . platform . defaultSign == ' s ' ) )
20482049 typeMaxValue = unsignedTypeMaxValue;
20492050 else if (bits >= mSettings .platform .int_bit && (!valueTok->valueType () || valueTok->valueType ()->sign != ValueType::Sign::SIGNED ))
20502051 typeMaxValue = unsignedTypeMaxValue;
@@ -2105,7 +2106,7 @@ void CheckConditionImpl::checkCompareValueOutOfTypeRange()
21052106 }
21062107 if (!error || diag (tok))
21072108 continue ;
2108- compareValueOutOfTypeRangeError (valueTok, typeTok-> valueType () ->str (), kiv, result);
2109+ compareValueOutOfTypeRangeError (valueTok, typeVt ->str (), kiv, result);
21092110 }
21102111 }
21112112 }
0 commit comments