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)


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




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