Is this legal C?

smh at mit-eddie.UUCP smh at mit-eddie.UUCP
Wed Nov 23 22:25:42 AEST 1983


References: utcsrgv.2783 <2454 at yale-com.UUCP>
Relay-Version:version B 2.10.1 6/24/83; site duke.UUCP
Posting-Version:version B 2.10.1 6/24/83; site mit-eddie.UUCP
Path:duke!decvax!genrad!mit-eddie!smh
Message-ID:<951 at mit-eddie.UUCP>
Date:Wed, 23-Nov-83 07:25:42 EST
Organization:MIT, Cambridge, MA

A minor quibble with Jerry Leichter, who writes:
---------------------------------------------
Consider setjmp/longjmp.  The standard way to use them is:

	if (setjmp(&buf) == 0)
	{	do something	}
	else
	{	handle the low-level error	}

This has the same control-passing structure as your goto example, once
the stack has been unwound.  Now, setjmp/longjmp are not part of the
language; but they have become pretty universal, and any compiler that
made them unimplementable would likely not gain much of a following.
---------------------------------------------
To the compiler there is a significant difference between a label on
an `if' conditional and the `setjmp' function call.  The former
requires the compiler generate code (if only an assembler label) while
the latter is a function which `magically' bashes -- whoops, I mean
restores -- the stack environment identically when `longjmp' is later
called.  `setjmp' is part of the object library environment, not the
language, and it would be incorrect for any C *compiler* to treat it
specially.

Steve Haflich, MIT Experimental Music Studio



More information about the Comp.lang.c mailing list