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 20449 - integer literal specification and implementation differs #10673

Closed
wants to merge 1 commit into from

Conversation

dkorpel
Copy link
Contributor

@dkorpel dkorpel commented Dec 14, 2019

This is assuming we want to adjust the implementation to conform to the spec, and not the other way around.

@dlang-bot
Copy link
Contributor

dlang-bot commented Dec 14, 2019

Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
20449 normal integer literal specification and implementation differs

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#10673"

}
else
result = TOK.int64Literal;
break;
case FLAGS.long_:
Copy link
Member

Choose a reason for hiding this comment

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

Just remove this line then ?

@ghost
Copy link

ghost commented Dec 15, 2019

What about auto x = 9223372036854775808L;? Will this compile in the new version?

According to the specs it shouldn't, but it feels a little bit strange to me that adding an L suffix reduces the amount of accepted values.

@Geod24
Copy link
Member

Geod24 commented Dec 15, 2019

According to the specs it shouldn't, but it feels a little bit strange to me that adding an L suffix reduces the amount of accepted values.

L is asking for a type explicitly. It's a bit redundant with auto x = long(value);, but that syntax is only available since a few years while the suffix approach dates back from C.
So if you ask for a type but the argument you provide does not fit in, it makes sense that the compiler errors out, doesn't it ?

@ghost
Copy link

ghost commented Dec 15, 2019

L is asking for a type explicitly.

Does it? It could also be seen, that this literal uses 64 bits and not only 32.

Anyway, I just wanted to point out, that there might be a problem. For me, the fix is fine.

@WalterBright
Copy link
Member

Because it's been implemented this way for 19 years now, and the compiler behavior matches C, I recommend that the spec change rather than the compiler.

@WalterBright
Copy link
Member

I changed the bugzilla issue to be a spec bug rather than a compiler bug.

@dkorpel dkorpel deleted the fix-integer-overflow branch December 16, 2019 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants