[Mono-list] LCC and CIL
Gonzalo Paniagua Javier
gonzalo@gnome-db.org
Tue, 12 Mar 2002 23:25:16 +0100
* [ Dominic Cooney <dominic@dcooney.com>
* Tue, 12 Mar 2002 22:47:19 +0100 ]
> I guess I need to brush up on my C! gcc allows this:
>
> #include <setjmp.h>
>
> jmp_buf env_buf;
>
> int funcA()
> {
> int v = setjmp(env_buf);
> printf("setjmp returned %d\n", v);
> return v;
> }
>
> int main()
> {
> if (!funcA())
> longjmp(env_buf, 1);
> }
>
> gcc's executable works correctly, and I thought the program was legal.
> MSVC++ accepts it and prints "setjmp returned 0, setjmp returned 1" but
> then crashes.
The man page for 'setjmp' doesn't guarantee that code works:
"The stack context will be invalidated if the function which
called setjmp() returns."
So, may be MSVC++'s behavior could be expected.