lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, 27 Jul 2009 12:55:23 +0300, Juris Kalnins <juris@mt.lv> wrote:

Lua error mechanism only require setjmp/longjmp, not C++ exceptions.
Are you sure -fexceptions is needed for setjmp/longjmp to work ? IIRC
-fexceptions generate data needed for destructors to be called, which
setjmp/longjmp and thus Lua error mechanism do not need.

But c++ does need it. It runs destructors on function exit. You cannot simply discard stack frames in C++. (And see above example for why it is bad for C, too).

Sorry, this reply was unnecessarily terse. To clarify: problem is not that setjmp doesn't work with -fno-exceptions, but that C++ throw/catch cannot be used with -fno-exceptions, and thus any Lua exception that unwinds C++ stack frame is an error. In other words, it is not possible to call most of Lua API from C++ functions that have non-trivial local variables, if Lua doesn't use C++ throw for exception handling.