sol2 icon indicating copy to clipboard operation
sol2 copied to clipboard

Warning with `require_file`

Open htv04 opened this issue 3 years ago • 0 comments
trafficstars

I'm currently using Lua 5.1 (LuaJIT). When using the require_file function, I'm getting this error:

(More "inlined from" statements above this but they're not important)
    inlined from 'sol::optional<sol::basic_object<sol::basic_reference<false> > > sol::state_view::is_loaded_package(const std::string&)' at sol/state_view.hpp:50:82:
sol/compatibility/compat-5.3.h:290:16: warning: array subscript 'const char [8][0]' is partly outside array bounds of 'const char [7]' [-Warray-bounds]
  290 |   (lua_getfield((L), (i), (k)), lua_type((L), -1))
      |    ~~~~~~~~~~~~^~~~~~~~~~~~~~~
sol/stack_field.hpp:116:49: note: in expansion of macro 'lua_getfield'
  116 |                                                 lua_getfield(L, tableindex, &key[0]);

Looking at the traceback, I found this line: https://github.com/ThePhD/sol2/blob/4de99c5b41b64b7e654bf8e48b177e8414a756b7/include/sol/state_view.hpp#L50

It seems that making these two strings the same length (which would cause issues for Lua though) fixes the warning, so could the error be related to string comparison somehow?

htv04 avatar Aug 23 '22 13:08 htv04