[comp.lang.c++] No return

eppstein@garfield (David Eppstein) (01/19/89)

Since everyone else already seems to be doing so, let me join the
discussion of "just one more feature" that should be added to C/C++.
My proposal: a new type, for functions that never return, i.e. they call
longjmp() or exit(), or they end in an infinite loop, or they call other
such functions.

This would let the compiler complain when such a function might actually
return, as well as eliminating the current bogus complaints when a
function with a return value type calls say exit() and then falls off the end.

It would also help the optimizer by letting it flush more dead code (no
big deal -- it's just code space not run time) and by not killing live
expressions killed in blocks ending in calls to such functions (this
could be more important).  Dead destructors could be dealt with by AT&T
cfront, but for the rest of these benefits the feature would either need
to be included in C itself, or you would need a native C++ compiler.

The best syntax would be an actual type keyword to use instead of void.
I like "goto" but that screws up the syntax of the language.  So how about
"noreturn".  Second best would be a pragma e.g. "#pragma noreturn longjmp".
-- 
David Eppstein  eppstein@garfield.cs.columbia.edu  Columbia U. Computer Science