[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: is it possible to make longjmp-free Lua?
- From: "Juris Kalnins" <juris@...>
- Date: Mon, 27 Jul 2009 14:47:07 +0300
On Mon, 27 Jul 2009 12:55:23 +0300, Juris Kalnins <email@example.com> 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.