functions that don't return

Don Lindsay lindsay at tl-vaxa.UUCP
Sat Sep 20 12:30:46 AEST 1986

There has been some discussion about functions that never return (e.g exit).
It was suggested that if a compiler could be told about this, then it
could generate better code.

In fact, these functions sometimes DO return (and in that case, the compiler
had better have allowed for that). 

For example, a storage allocator may decide to exit, because his caller has
reached some limit. But, the developer of this storage allocator wishes to
write a test program, and she wants the test program to exercise this
feature. The test program can be more powerful, and more convenient, and easier
to document and use, if it can make the "exit" routine return !

Similarly, a program may detect an unusual condition, and call a handler
for it. It is more general if it is the handler which decides whether or
not to return. (Perhaps one would link in different handlers under different
circumstances.) It is quite common for people to write over-specified
programs, where the mainline "knows" what kind of handler is out there.
The existence of a new function type would mostly encourage such limited

Don Lindsay

More information about the Comp.lang.c mailing list