Re: Why the setjmp and longjmp I wrote can not work?
Date: Sun, 06 Nov 2005 12:17:10 -0800
"Zheng Da" <email@example.com> writes:
> #include <stdio.h>
Your program as posted doesn't compile:
junk.c: In function `mysetjmp':
junk.c:13: error: subscripted value is neither array nor pointer
junk.c:16: error: subscripted value is neither array nor pointer
... etc ...
Fixing these ...
> When the computer execute jmp %2, and gives me a segment fault.
Nope. It crashes *before* it reaches that instruction.
Learn to use the debugger to figure that out.
> I do not know why the address I save is a invalid address, and wonder
> to know what should I do if I want that mysetjmp and mylongjmp can work
The 'mylongjmp' can't be reasonably implemented with inline assembly.
You'll have to use "pure" assembly if you are to have any chance
of success. Also note that setjmp/longjmp must save *all* registers.
At a minimum you must save/resore %esp in addition to %ebp.
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
- Re: char **argv & char *argv
... "pointer to pointer to char". ... >> pointer)) pointing to the first element of an array. ... so we have to start adding more context. ... type "pointer to char", rather than "array MISSING_SIZE of char". ...
- Re: Who owns the variable in my header file ?
... to check the subscripts to the array and trap on error conditions. ... cast one type of pointer into another; you wouldn't then be able to step ... language trying to be C like, ... One reason being that the programmer can possible ...
- Re: why cannot assign to function call
... hypothetical C-like languages, ... sizeof business would still indicate that a pointer was being passed. ... talk about variables of an array type. ... the earlier version of the standard didn't have numbered ...
- Re: multi dimensional arrays as one dimension array
... please - where does the standard say that such a conversion ... Pointer conversion yields a pointer to the same object as ... exist only where there are array declarations. ...
- Re: Pointer Equality for Different Array Objects
... Pointers to the same object are pointers to the same region of data storage. ... A pointer comaprison (for exact equality, ... we have the vague ("if the array is large enough"). ...