Skip to content

Commit

Permalink
move static_assert from ltable.h to ltable.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
LoganDark committed Nov 9, 2021
1 parent 9523670 commit c86dff4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 1 addition & 0 deletions VM/src/ltable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ LUAU_FASTFLAGVARIABLE(LuauArrayBoundary, false)
#define MAXBITS 26
#define MAXSIZE (1 << MAXBITS)

static_assert(offsetof(LuaNode, val) == 0, "Unexpected Node memory layout, pointer cast in gval2slot is incorrect");
// TKey is bitpacked for memory efficiency so we need to validate bit counts for worst case
static_assert(TKey{{NULL}, 0, LUA_TDEADKEY, 0}.tt == LUA_TDEADKEY, "not enough bits for tt");
static_assert(TKey{{NULL}, 0, LUA_TNIL, MAXSIZE - 1}.next == MAXSIZE - 1, "not enough bits for next");
Expand Down
1 change: 0 additions & 1 deletion VM/src/ltable.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#define gval(n) (&(n)->val)
#define gnext(n) ((n)->key.next)

static_assert(offsetof(LuaNode, val) == 0, "Unexpected Node memory layout, pointer cast below is incorrect");
#define gval2slot(t, v) int(cast_to(LuaNode*, static_cast<const TValue*>(v)) - t->node)

LUAI_FUNC const TValue* luaH_getnum(Table* t, int key);
Expand Down

0 comments on commit c86dff4

Please sign in to comment.