Skip to content

Fix coverity issue: part 3 #30145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,15 @@ bool extend_reverse_type(const std::shared_ptr<ov::Node>& node, const precisions

template <typename src_type, typename dst_type>
inline dst_type convert_value(src_type val) {
if (val > std::numeric_limits<dst_type>::max()) {
return std::numeric_limits<dst_type>::max();
} else if (val < std::numeric_limits<dst_type>::lowest()) {
return std::numeric_limits<dst_type>::lowest();
if (std::numeric_limits<src_type>::max() > std::numeric_limits<dst_type>::max()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: execute it in compile time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (std::numeric_limits<src_type>::max() > std::numeric_limits<dst_type>::max()) {
if constexpr (std::numeric_limits<src_type>::max() > std::numeric_limits<dst_type>::max()) {

if (val > std::numeric_limits<dst_type>::max()) {
return std::numeric_limits<dst_type>::max();
}
}
if (std::numeric_limits<src_type>::lowest() < std::numeric_limits<dst_type>::lowest()) {
if (val < std::numeric_limits<dst_type>::lowest()) {
return std::numeric_limits<dst_type>::lowest();
}
}
return static_cast<dst_type>(val);
}
Expand Down
Loading