Skip to content
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

Fix % and remainder of min int value against -1 #8321

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

asterite
Copy link
Member

Fixes #8306

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric labels Oct 13, 2019
{% begin %}
if other == 0
raise DivisionByZeroError.new
elsif self < 0 && self == {{@type}}::MIN && other == -1
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens for other == -2 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems to work fine. It gives 0.

Copy link
Member

Choose a reason for hiding this comment

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

That should be a spec

Copy link
Member Author

Choose a reason for hiding this comment

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

But the bug mentioned -1 specifically. I'm not sure we need to add specs for -2, -3 or possibly any number that might have a bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC it stresses different path in the code, so it might be worth having a test coverage for it?

@RX14 RX14 added this to the 0.32.0 milestone Oct 23, 2019
@RX14 RX14 merged commit 8b4fce8 into crystal-lang:master Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Int64::MIN % -1_i64) -> Program received and didn't handle signal FPE (8)
6 participants