[Mono-list] LCC and CIL

Dominic Cooney dominic@dcooney.com
Thu, 14 Mar 2002 08:05:43 +1000


s/works correctly/doesn't crash and prints "setjmp returned 0, setjmp
returned 1"/gi

Sorry

-----Original Message-----
From: mono-list-admin@ximian.com [mailto:mono-list-admin@ximian.com] On
Behalf Of Michael Poole
Sent: Wednesday, 13 March 2002 8:25 AM
To: Dominic Cooney
Cc: mono-list@ximian.com
Subject: Re: [Mono-list] LCC and CIL

"Dominic Cooney" <dominic@dcooney.com> writes:

> 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.

What is "works correctly"?  I don't have an ANSI/ISO C spec handy, but
http://www.opengroup.org/onlinepubs/007908799/xsh/longjmp.html (the
longjmp() specification from SuSv2) says that the behavior of
longjmp(env_buf, ...) is undefined if the corresponding
setjmp(env_buf) was called from a function that has returned.  This is
the case in the above code.

-- Michael Poole

_______________________________________________
Mono-list maillist  -  Mono-list@ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list