Open FranchescaMullin opened 1 year ago
I think this may be caused by a GCC bug. It looks like the GCC static analyzer is seeing that somewhere the function gets called with a null-terminated string of a certain length (30 in my case, I guess 10 with the null terminator in yours), and reads the whole thing, and assumes it will always read that many bytes. @FranchescaMullin is there somewhere else in your program where you have a nine-character argument to .get
?
You are definitely on to something!
My first call to get is the following (10 characters long):
sol::optional<std::string> pricerType = config.get<sol::optional<std::string>>("pricerType");
As an experiment to test your theory, I tried to compile it with the field name lengthened to 17 chars:
sol::optional<std::string> pricerType = config.get<sol::optional<std::string>>("pricerTypezzzzzzz");
and I get the following error:
/redacted/include/sol/stack_field.hpp:116:61: error: array subscript ‘const char [18][0]’ is partly outside array bounds of ‘const char [17]’ [-Werror=array-bounds] 116 | lua_getfield(L, tableindex, &key[0]);
The line of code generating the error is as follows (16 chars long):
config.get<sol::optional<std::string>>("frontMonthSymbol");
If I drop the number of chars in the first call to get to 16 chars, the whole thing compiles fine.
Hi, thanks for making a great library. I am a bit puzzled by a strange compile error I am getting right now. Not sure if I am doing something silly or if this is really a bug?
Here are some details:
config
is of typeconst sol::table& config
and is passed to the example code as a parameter in a methodThis compiles fine:
sol::optional<std::string> currency = config.get<sol::optional<std::string>>("currencyyyyyy");
But this line gives a compile error:sol::optional<std::string> currency = config.get<sol::optional<std::string>>("currency");
I played around, and basically the field name passed to .get must be > 9 chars or it will not compile.
Example error:
Include Compiler/IDE (Visual Studio, XCode...), Build and Deployment System, Language (C++, Objective-C++), and any special defines you have set: