This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -fobey-inline (was Re: gcc and inlining)


On 14-Mar-2003, Andrea 'fwyzard' Bocci <fwyzard-gcc at libero dot it> wrote:
> Is the following legal C code ?
> It also has different scopes for setjmp() and longjmp(), and it's what I'd 
> expect from inlining the above example.
> 
> #include <setjmp.h>
> static jmp_buf buf;
> 
> int main (void) {
>   {
>     setjmp(buf);
>   }
>   longjmp(buf);
> }

Yes, that is strictly conforming C89 and C99 code.
The criteria is whether the containing function has terminated,
not whether the scope containing the setjmp() has been exited.

However, in C99 there is an exception.  If the scope contains a
variably-modified object, as in the following example, it is
undefined behaviour:

	int main (int argc, char **argv) {
	   {
	     char foo[argc];
	     setjmp(buf);
	   }
	   longjmp(buf);	// undefined behaviour, because foo has
	   			// variably-modified type and is no
				// longer in scope
	}

-- 
Fergus Henderson <fjh at cs dot mu dot oz dot au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]