This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -fobey-inline (was Re: gcc and inlining)
- From: Fergus Henderson <fjh at cs dot mu dot OZ dot AU>
- To: "Andrea 'fwyzard' Bocci" <fwyzard-gcc at libero dot it>
- Cc: Dale Johannesen <dalej at apple dot com>, Robert Dewar <dewar at gnat dot com>, echristo at redhat dot com, Richard dot Earnshaw at arm dot com, aph at redhat dot com, gcc at gcc dot gnu dot org
- Date: Sat, 15 Mar 2003 05:40:57 +1100
- Subject: Re: -fobey-inline (was Re: gcc and inlining)
- References: <20030314024626.1F4CFF2941@nile.gnat.com> <5.2.0.9.2.20030314184136.02530b18@popmail.libero.it>
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.