Skip to content

Use numeric_cast_v<unsigned> instead to_ulong with incompatible types [blocks: #3800] #3879

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

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/goto-instrument/accelerate/acceleration_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ void acceleration_utilst::extract_polynomial(
std::map<exprt, int> degrees;

mp_integer mp=binary2integer(concrete_term.get_value().c_str(), true);
monomial.coeff=mp.to_long();
monomial.coeff = numeric_cast_v<int>(mp);

if(monomial.coeff==0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/util/arith_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ mp_integer power(const mp_integer &base,
case 2:
{
mp_integer result;
result.setPower2(exponent.to_ulong());
result.setPower2(numeric_cast_v<unsigned>(exponent));
return result;
}
case 1: return 1;
Expand Down
7 changes: 1 addition & 6 deletions src/util/ieee_float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Author: Daniel Kroening, [email protected]

#include "ieee_float.h"

#include <cstdint>
#include <ostream>
#include <cmath>
#include <limits>
Expand Down Expand Up @@ -1242,11 +1241,7 @@ float ieee_floatt::to_float() const
return std::numeric_limits<float>::quiet_NaN();
}

mp_integer i=pack();
CHECK_RETURN(i.is_ulong());
CHECK_RETURN(i <= std::numeric_limits<std::uint32_t>::max());

a.i=i.to_ulong();
a.i = numeric_cast_v<uint32_t>(pack());
return a.f;
Copy link
Member

Choose a reason for hiding this comment

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

Use uint32_t instead of unsigned?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, and will then remove the above CHECK_RETURN as numeric_cast_v subsumes these.

}

Expand Down