Possible bug in luabind::call_function when building with LUABIND_NO_ERROR_CHECKING

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Possible bug in luabind::call_function when building with LUABIND_NO_ERROR_CHECKING

Evan Odabashian
I'm compiling luabind-0.9 directly into my project with Visual Studio 2008. I was trying to setup my release configuration to use LUABIND_NO_ERROR_CHECKING for better performance and I seem to have run into a problem with luabind::call_function returning null return values when it wasn't with error checking enabled.

I think this code at line 140 of call_function.hpp is the problem:

#ifndef LUABIND_NO_ERROR_CHECKING

                    if (converter.match(L, LUABIND_DECORATE_TYPE(Ret), -1) < 0)
                    {
                             // error reporting here
                    }
#endif
                    return converter.apply(L, LUABIND_DECORATE_TYPE(Ret), -1);

It looks like converter.match is what does all the actual work to retrieve and convert the return value, and that converter.apply is effectively just a static_cast to the specified type. When LUABIND_NO_ERROR_CHECKING is defined however the call to 'match' gets compiled out.

I would guess something the following would fix the problem:

int result = convert.match(...)

#ifndef LUABIND_NO_ERROR_CHECKING
if (result < 0)
// error
#endif
return converter.apply(L, LUABIND_DECORATE_TYPE(Ret), -1);

Maybe I'm misinterpreting this code, but there's definitely a difference in the behavior of this function depending on if LUABIND_NO_ERROR_CHECKING is defined, so even if I'm wrong about the exact nature of the problem maybe this is enough for somebody else to spot the real problem.

Thanks,
Evan

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user