Lua variable to std::string fails on VS2015
Zardoz89 opened this issue · 3 comments
I just try this, that works on gcc 4.9 on my Linux box :
std::string out = lua_state["bar"][3];
_log.info() << "LUA: " << out;
Simply crash on VS2015 with Lua 5.2
How ever if I try, calling explicitly std::string conversion operator, it works :
auto sel = lua_state["bar"][3];
std::string out = sel.operator std::string();
log->info() << "LUA: " << out;
Is there a crash error?
Exception thrown at 0x010EE486 in TEC.exe: 0xC0000005: Access violation reading location 0x00000014.
The code that throw the exception is inside on "xstring" lib of VStudio :
size_type size() const _NOEXCEPT
{ // return length of sequence
return (this->_Mysize());
}
Looks that the moment of throwing the exception, the basic_string object isn't correctly initialized -----> Comes from here :
Were _MyT is : typedef basic_string<_Elem, _Traits, _Alloc> _Myt;
I usually work with valgrind, kdgb & cia on Linux. I don't know very well VStudio to get more useful information. But, I think that is using the copy constructor instead of building a string from a char array.