forked from LuaJIT/LuaJIT
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bit op coercion in DUALNUM builds.
Thanks to Sergey Kaplun. (cherry picked from commit f5fd222) The `lj_carith_check64()` function coerces the given number value to the 32-bit wide value. In this case, the 64-bit-wide operands will lose upper bits. This patch removes the excess coercion for the DUALNUM mode and drops the corresponding skipcond introduced for the test in the previous commit. Sergey Kaplun: * added the description and the test for the problem Part of tarantool/tarantool#10199
- Loading branch information
Showing
3 changed files
with
20 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
test/tarantool-tests/lj-1273-dualnum-bit-coercion.test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
local tap = require('tap') | ||
|
||
-- Test file to demonstrate LuaJIT misbehaviour on operating | ||
-- for 64-bit operands in built-in `bit` library in DUALNUM mode. | ||
-- See also, https://github.com/LuaJIT/LuaJIT/issues/1273. | ||
|
||
local test = tap.test('lj-1273-dualnum-bit-coercion') | ||
test:plan(1) | ||
|
||
local bit = require('bit') | ||
|
||
-- The cdata value for 2 ^ 33. | ||
local EXPECTED = 2 ^ 33 + 0LL | ||
-- Same value is used as mask for `bit.band()`. | ||
local MASK = EXPECTED | ||
|
||
test:is(bit.band(2 ^ 33, MASK), EXPECTED, 'correct bit.band result') | ||
|
||
test:done(true) |