Skip to content

Conversation

@tautschnig
Copy link
Collaborator

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.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

if(to_integer(src, int_value))
UNREACHABLE;
const wchar_t int_value = numeric_cast_v<wchar_t>(src);

Copy link
Collaborator

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'.

Copy link
Collaborator

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.

Copy link
Contributor

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.

Copy link
Contributor

@allredj allredj left a 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);
}
Copy link
Collaborator

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.

@thk123
Copy link
Contributor

thk123 commented Nov 5, 2018

TG failure looks spurious - I have restarted it.

Copy link
Contributor

@allredj allredj left a 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.

{
mp_integer value;
assert(!to_integer(e, value));
mp_integer value = numeric_cast_v<mp_integer>(e);
Copy link
Contributor

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())
Copy link
Contributor

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)

const exprt &val_expr=oit->op1();
mp_integer value;
to_integer(val_expr, value);
mp_integer value = numeric_cast_v<mp_integer>(val_expr);
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

also could be const

Copy link
Contributor

@romainbrenguier romainbrenguier left a 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.

Copy link
Collaborator

@martin-cs martin-cs left a 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.

it!=used_bits_map.end();
it++)
{
// this is unmaintained code, don't try to reformat it
Copy link
Member

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?

Copy link
Collaborator Author

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);
/**
Copy link
Member

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.
@peterschrammel peterschrammel removed their assignment Nov 5, 2018
… 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.
@tautschnig tautschnig assigned tautschnig and unassigned smowton and thk123 Nov 5, 2018
Copy link
Contributor

@allredj allredj left a 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

@tautschnig tautschnig merged commit b0d28c8 into diffblue:develop Nov 5, 2018
@tautschnig tautschnig deleted the vs-no-to_integer branch November 5, 2018 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants