Skip to content

Unit tests for simplify expression #1075

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

Closed

Conversation

thk123
Copy link
Contributor

@thk123 thk123 commented Jun 29, 2017

I am not sure the change is correct - but either way we should have unit tests that verify the behaviour so it is documented.

The question is should a type cast from an integral type to an integral type, where the destination is >= the source (e.g. casting from a 32 bit signed integer to a 64 bit signed integer), should the typecast be removed?

These unit tests verify that they should, but currently they are not. The commit thk123@c6387e9 means that they are.

Found this trying to fix a different bug but this turned out to be unrelated.

@thk123
Copy link
Contributor Author

thk123 commented Jun 29, 2017

The linting error relates to #1038

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

The question is should a type cast from an integral type to an integral type, where the destination is >= the source (e.g. casting from a 32 bit signed integer to a 64 bit signed integer), should the typecast be removed?

No, not in general. See the comments at the beginning of this branch of the code, which in particular mention overflow.

For constants the story is a different one, but this is already handled further down below in that function.

WHEN("Simplifying a[(signed long int)0]")
{
exprt out_expr;
bool success=language.to_expr("a[(signed long int)0]", "", out_expr, ns);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't a success flag, but a failed flag.

@tautschnig tautschnig changed the base branch from master to develop August 22, 2017 12:22
@thk123
Copy link
Contributor Author

thk123 commented Feb 7, 2020

Replaced by #5229

@thk123 thk123 closed this Feb 7, 2020
@thk123 thk123 deleted the feature/unit-test-simplify-expr branch February 7, 2020 15:28
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.

2 participants