Skip to content

-O2 changes the result of == between vector constants #2967

Description

@tidusec

In a LUA_VECTOR_SIZE 3 build, a surplus 4th argument to vector.create affects ==
at -O2 but not at -O0/-O1.

print(vector.create(1, 2, 3) == vector.create(1, 2, 3, 9))
luau -O0  -->  true
luau -O1  -->  true
luau -O2  -->  false

Both sides print 1, 2, 3, and .x/.y/.z compare equal at every level.

Two more observations that may help narrow it:

  • At -O2, == and rawequal disagree on the same pair:
    a == b is false while rawequal(a, b) is true.
  • It only affects constant-folded operands. With
    local function mk(x,y,z) return vector.create(x,y,z) end,
    mk(1,2,3) == vector.create(1,2,3,9) is true at -O2.

Rebuilding the same source with LUA_VECTOR_SIZE 4 gives false at all three levels,
which is correct for a 4-wide build. The divergence is 3-wide only.

tests/conformance/vector.luau passes unmodified at -O0/-O1/-O2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions