Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N18.
The value of the 'sourceDim' index is checked after it was used.
Reviewed By: zero9178
Differential Revision: https://reviews.llvm.org/D142312
break;
int64_t currTargetShape = targetShape[targetDim];
- while (sourceShape[sourceDim] != ShapedType::kDynamic &&
- prodOfCollapsedDims * sourceShape[sourceDim] < currTargetShape &&
- sourceDim < sourceShape.size()) {
+ while (sourceDim < sourceShape.size() &&
+ sourceShape[sourceDim] != ShapedType::kDynamic &&
+ prodOfCollapsedDims * sourceShape[sourceDim] < currTargetShape) {
prodOfCollapsedDims *= sourceShape[sourceDim];
currIndices.push_back(sourceDim++);
}