On 21 Sep 2005, at 01:13, Paul Eggert wrote:
2. Avoid memory leaks when a C signal handler does a setjmp out of a
parser. Traditionally this has been useful for programs that
read and parse input interactively, and that trap signals and use
longjmp in signal handers.
...
As for (2), how are C++ programs supposed to prevent memory leaks in
such situations? Does lalr1.cc handle this correctly? (glr.c
doesn't, not that I'm tempted to modify it to handle this....)
If one uses exception handling instead of longjmp, then cleanup can
be made automatic. In particular, it is, if one uses the standard
classes std::stack, std::deque, etc. If one mixes exceptions with
longjmp, that can result in undefined behavior. One advantage with C+
+ is its automatic cleanup; one drawback is that in the current C++
revision (which may change in the future), is that it is difficult to
implement a GC, other than a reference count.
Hans Aberg