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: Segher Boessenkool <segher at koffie dot nl>
- To: Dale Johannesen <dalej at apple dot com>
- Cc: 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 07:37:13 +0100
- Subject: Re: -fobey-inline (was Re: gcc and inlining)
- References: <9BA5B65A-55C8-11D7-B9FE-000393D76DAA@apple.com>
Dale Johannesen wrote:
Those of you who think inlining is guaranteed to be semantically neutral
might consider this....
#include <setjmp.h>
static jmp_buf buf;
inline void x() { setjmp(buf); }
main() { x(); longjmp(buf); }
6.7.4 Function specifiers
3 An inline definition of a function with external
linkage shall not contain a definition of a
modifiable object with static storage duration,
and shall not contain a reference to an
identifier with internal linkage.
x() has external linkage; buf has internal linkage.
This program is non-conforming. Either x() should be
declared static, or buf should not.
With that fixed, we still have
7.13.2.1 The longjmp function
2 The longjmp function restores the environment
saved by the most recent invocation of the setjmp
macro in the same invocation of the program with
the corresponding jmp_buf argument. If there has
been no such invocation, or if the function containing
the invocation of the setjmp macro has terminated
execution in the interim, [...] the behavior is
undefined.
x() has terminated execution when longjmp() is called
(there is a sequence point inbetween), so this program
is non-conforming.
Well that's how I read the standard, but IANALL, of course.
Does this help?
Segher