Re: Exception in C



On Aug 31, 12:17 pm, Laurent Deniau <Laurent.Den...@xxxxxxxxx> wrote:
For who are interested, I have updated my exception module (very
small) that I published on the web few years ago. It is now compatible
with multithreads (TLS) to follow a growing demand for an update of my
old code which wasn't. It is a complete refactoring imported and
adapted (simplied) from the C Object System for C89.

I think that what you're doing can invoke unexpected behavior on some
platforms. According to C99 (which I realize you're not using, but I
highly doubt the longjmp() restrictions would be more constraining),
"the values of objects of automatic storage duration that are local to
the function containing the invocation of the corresponding setjmp
macro that do not have volatile-qualified type and have been changed
between the setjmp invocation and longjmp call are indeterminate." For
your EX_TRY macro, you're defining a struct ex_cxt object with
automatic storage duration named ex_lcxt which gets modified inside
ex_throw() (albeit through a different variable at that point) before
longjmp() is called, so when execution gets to EX_CATCH() or
EX_CATCH_ANY(), it's perfectly legal for ex_cxt to be total garbage.

.



Relevant Pages

  • Re: Exception in C
    ... highly doubt the longjmp() restrictions would be more constraining), ... macro that do not have volatile-qualified type and have been changed ... between the setjmp invocation and longjmp call are indeterminate." ...
    (comp.lang.c)
  • Re: local jump by longjmp()
    ... Can longjmp() be used for local jump? ... not a macro, a jump performed by the function is not local unless we ... The standard describes longjmp as a function, ...
    (comp.std.c)
  • Re: local jump by longjmp()
    ... not a macro, a jump performed by the function is not local unless we ... The standard describes longjmp as a function, ... It is unspecified whether setjmp is a macro or an identifier declared ...
    (comp.std.c)
  • Re: local jump by longjmp()
    ... Keeping in mind the standards require longjmp to be a function, ... As said by Keith Thompson, the standard never reuiqres it. ... additionally to be a macro. ...
    (comp.std.c)