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

Bitwise: Fix overflow from Vim 8.0.0219 #481

Merged
merged 2 commits into from Feb 9, 2017
Merged

Bitwise: Fix overflow from Vim 8.0.0219 #481

merged 2 commits into from Feb 9, 2017

Conversation

lambdalisue
Copy link
Member

Vim 8.0.0219 change the behavior of overflow and now any literal
larger than or equal to 0x8000000000000000 will be rounded to
0x7FFFFFFFFFFFFFFF.

To fix this problem, create values without using literal in code and tests.

#479

こんなんでどうでしょう?

Copy link
Member

@thinca thinca left a comment

Choose a reason for hiding this comment

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

テスト通ったらマージします!

@@ -1,6 +1,11 @@
Describe Bitwise
Before all
let B = vital#vital#new().import('Bitwise')
" NOTE:
" A int literal larger than or equal to 0x8000000000000000 will be rounded
Copy link
Member

Choose a reason for hiding this comment

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

An

@@ -1,6 +1,11 @@
Describe Bitwise
Before all
let B = vital#vital#new().import('Bitwise')
" NOTE:
" A int literal larger than or equal to 0x8000000000000000 will be rounded
" to 0x7FFFFFFFFFFFFFFF after Vim 8.0.0219 so create it without literal
Copy link
Member

Choose a reason for hiding this comment

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

s/so/, so/

@@ -227,14 +232,20 @@ Describe Bitwise
if has('num64')
Context with 64bit number
It applies sign extension
" NOTE:
" A int literal larger than or equal to 0x8000000000000000 will be rounded
" to 0x7FFFFFFFFFFFFFFF after Vim 8.0.0219 so create it without literal
Copy link
Member

Choose a reason for hiding this comment

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

(same)

Vim 8.0.0219 change the behavior of overflow and now any literal
larger than or equal to 0x8000000000000000 will be rounded to
0x7FFFFFFFFFFFFFFF.

To fix this problem, create values without using literal in code and tests.
@lambdalisue
Copy link
Member Author

テスト完了後にマージします

" to 0x7FFFFFFFFFFFFFFF after Vim 8.0.0219, so create it without literal
let s:xFFFFFFFF00000000 = has('patch-8.0.0219')
\ ? 0xFFFFFFFF * s:pow2[and(32, s:mask)]
\ : 0xFFFFFFFF00000000
Copy link
Member

Choose a reason for hiding this comment

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

ここの条件分岐は必要?

Copy link
Member Author

Choose a reason for hiding this comment

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

不要ですが

  1. 以前動いていた部分を変更する必要がない
  2. 変数名でわかりやすくしているが 0xFFFFFFFF00000000 が動くならそれが正しいんだよ、ってのをコード的に表現したかった

って感じで分岐してます。関数呼び出しが一回分増えるコストがありますが、無視できるかなと

Copy link
Member

Choose a reason for hiding this comment

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

了解。

@lambdalisue lambdalisue merged commit 2a47768 into master Feb 9, 2017
@lambdalisue lambdalisue deleted the fix-bitwise branch February 9, 2017 19:08
@lambdalisue
Copy link
Member Author

🎉

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.

None yet

4 participants