-
Notifications
You must be signed in to change notification settings - Fork 274
Use appropriate numeric_cast_v<T> instead of deprecated integer2unsigned #3047
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
Conversation
f8e589f
to
dd50d12
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR failed Diffblue compatibility checks (cbmc commit: f8e589f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85989246
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: dd50d12).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86004982
dd50d12
to
7c3ad9b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: 7c3ad9b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86294489
@@ -549,10 +549,12 @@ exprt flatten_byte_update( | |||
// zero-extend the value, but only if needed | |||
exprt value_extended; | |||
|
|||
if(width>integer2unsigned(element_size)*8) | |||
if(width > element_size * 8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks inconsistent: width
is a size_t
(which is parsed with integer2size_t
above). element_size
is an mp_integer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thus everything will be converted to mp_integer
, which avoids falling for an (unsigned) integer overflow.
src/util/string_constant.cpp
Outdated
unsigned unsigned_value=integer2unsigned(int_value); | ||
value+=static_cast<char>(unsigned_value); | ||
|
||
value += numeric_cast_v<char>(op); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit worried about this one -- the previous implementation would have done the conversion, say from -1 to 255; now you get an invariant failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do negative numbers make sense in this context? I'm happy to amend this in any reasonable way. The code does not seem to be used anywhere, so I wouldn't know how to test, I'm afraid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3168 takes care of this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will rebase once that is merged.
This includes several type fixes - only three instances ended up as numeric_cast_v<unsigned>, all others uses of integer2unsigned were actually in contexts where some other type was required.
7c3ad9b
to
0c2f8c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed Diffblue compatibility checks (cbmc commit: 0c2f8c1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/87897801
This includes several type fixes - only three instances ended up as
numeric_cast_v, all others uses of integer2unsigned were actually in
contexts where some other type was required.