-
Notifications
You must be signed in to change notification settings - Fork 285
Use numeric_cast<mp_integer> instead of deprecated to_integer(exprt), part 2 #3260
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
6a6a684 to
fade8a8
Compare
| if(to_integer(src, int_value)) | ||
| UNREACHABLE; | ||
| const wchar_t int_value = numeric_cast_v<wchar_t>(src); | ||
|
|
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 is difficult. Java chars are fixed to be 16 bits, by the standard.
wchar_t may be 16 bits, or may be 32 bits, but there isn't an obvious connection to Java's concept of a 'char'.
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.
Also, signedness may differ. Java's char is unsigned.
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.
Hmm, thanks, I had inferred the type from what utf16_native_endian_to_java takes as parameter. What would be the right type to use here, and where should a possible cast happen?
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.
Anything that is guaranteed to hold an unsigned 16-bit values should work -- so how about "char16_t". I would then do an explicit cast to wchar_t when doing the call to utf16_native_endian_to_java. Really utf16_native_endian_to_java should take a char16_t.
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.
Yes char16_t should be used here and in utf16_native_endian_to_java.
allredj
left a comment
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: fade8a8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/90158915
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).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
| const auto i = numeric_cast<mp_integer>(expr); | ||
| if(i.has_value() && *i >= 0) | ||
| return integer2string(*i, 2); | ||
| } |
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.
Triggered #3262, will rebase once this is merged.
|
TG failure looks spurious - I have restarted it. |
allredj
left a comment
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: fade8a8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/90158915
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).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
src/analyses/invariant_set.cpp
Outdated
| { | ||
| mp_integer value; | ||
| assert(!to_integer(e, value)); | ||
| mp_integer value = numeric_cast_v<mp_integer>(e); |
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.
const
| mp_integer i; | ||
| if(!to_integer(expr, i)) | ||
| const auto i = numeric_cast<mp_integer>(expr); | ||
| if(i.has_value()) |
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.
could be written if(const auto i = numeric_cast<mp_integer>(expr)) (makes clear that i is only used in the if)
src/solvers/qbf/qdimacs_core.cpp
Outdated
| const exprt &val_expr=oit->op1(); | ||
| mp_integer value; | ||
| to_integer(val_expr, value); | ||
| mp_integer value = numeric_cast_v<mp_integer>(val_expr); |
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.
Since value is converted to ulong just afterwards it may make sense to directly cast to unsigned long here.
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.
also could be const
romainbrenguier
left a comment
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.
Nice. The utf16 issue should be fixed but is not related to this PR, so for me it's not blocking.
fade8a8 to
b07a78b
Compare
b07a78b to
bfd8234
Compare
martin-cs
left a comment
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.
The part that touches my world looks fine.
src/solvers/qbf/qdimacs_core.cpp
Outdated
| it!=used_bits_map.end(); | ||
| it++) | ||
| { | ||
| // this is unmaintained code, don't try to reformat it |
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.
Can't we just remove it?
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 have not bothered to look into this code, quite likely the entire qdimacs support is mostly broken?
| mp_integer over_i; | ||
| to_integer(over_expr, over_i); | ||
| mp_integer over_i = numeric_cast_v<mp_integer>(over_expr); | ||
| /** |
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.
Side remark (not to be done in this PR): we should replace these /* */ comments.
Java chars are fixed to be 16 bits by the standard.
… part 2 This further reduces the number of warnings flagged, in particular in Visual-Studio builds. Also turn tests of the size of ID_vector types being constants into invariants as was already done in some places.
bfd8234 to
b541bf9
Compare
allredj
left a comment
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: b541bf9).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/90326624
This further reduces the number of warnings flagged, in particular in
Visual-Studio builds. Also turn tests of the size of ID_vector types being
constants into invariants as was already done in some places.