Skip to content

Commit cd494b2

Browse files
committed
Added - Check known value also in integer range
1 parent 3b9c887 commit cd494b2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/checktype.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,12 @@ void CheckType::checkLongCast()
383383
const ValueType *type = tok->astOperand1()->valueType();
384384
if (type && checkTypeCombination(*type, *retVt, *mSettings) &&
385385
type->pointer == 0U &&
386-
type->originalTypeName.empty() &&
387-
!tok->astOperand1()->hasKnownIntValue())
388-
ret = tok;
386+
type->originalTypeName.empty()) {
387+
if (!tok->astOperand1()->hasKnownIntValue()) {
388+
ret = tok;
389+
} else if (!mSettings->platform.isIntValue(tok->astOperand1()->getKnownIntValue()))
390+
ret = tok;
391+
}
389392
}
390393
// All return statements must have problem otherwise no warning
391394
if (ret != tok) {

0 commit comments

Comments
 (0)