"Bernhard R. Link" <[EMAIL PROTECTED]> writes:

> #include <stdio.h>
> #include <setjmp.h>
> 
> void A(jmp_buf *j) {
>       int v;
> 
>       printf("[A\n");
>       v = setjmp(*j);
>       printf("A: setjmp returned %d\n",v);
>       printf("A]\n");
> }
> 
> void B(jmp_buf *j) {
>       printf("[B\n");
>       longjmp(*j,1);
>       printf("B]\n");
> }
> 
> int main() {
>       jmp_buf j;
> 
>       printf("[main\n");
>       A(&j);
>       printf("...main...\n");
>       B(&j);
>       printf("main]\n");
>       return 0;
> }

This code is invalid in two ways: setjump must not be used in an
assignment expression (which is unlikely to cause any actual problems,
though); and longjmp must not jump into a function which has been
terminated after the call to setjmp (which is likely the cause for the
crash).

(Note I haven't read the rest of the thread, this might be irrelevant)

-- 
        Falk


Reply via email to