mirror of
https://github.com/lua/lua.git
synced 2026-10-26 18:45:25 +00:00
Bug: wrong result for (-0.0 - 0)
(exp - i) was being optimized to (exp + (-i)), to use OP_ADDI, but (-0.0 - 0) is -0.0, while (-0.0 + 0) is +0.0, so the case (exp - 0) was excluded from the optimization.
This commit is contained in:
@@ -838,6 +838,11 @@ do
|
||||
local a1, a2, a3, a4, a5 = 0, 0, "\0\0\0\0\0\0\0\0", 0, "\0\0\0\0\0\0\0\0"
|
||||
assert(a1 == a2 and a2 == a4 and a1 ~= a3)
|
||||
assert(a3 == a5)
|
||||
|
||||
-- Bug since 5.4: Results differ for constant 0 versus variable 0;
|
||||
-- (mz - 0) should be -0.0, but it resulted in +0.0
|
||||
local zi = 0
|
||||
assert(1/(mz - 0) == 1/(mz - zi))
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user