Path: utzoo!utgpu!watmath!rbutterworth From: rbutterworth@watmath.waterloo.edu (Ray Butterworth) Newsgroups: comp.lang.c Subject: Re: Strange lint mumblings Message-ID: <22752@watmath.waterloo.edu> Date: 15 Dec 88 23:27:00 GMT References: <416@marob.MASA.COM> Organization: U of Waterloo, Ontario Lines: 27 In article <416@marob.MASA.COM>, daveh@marob.MASA.COM (Dave Hammond) writes: > Can anyone explain why the statement: > exit(0); /* followed immediately by main's closing brace */ > causes lint to complain: > (137) warning: main() returns random value to invocation environment If your doesn't have something like "extern void /*GOTO*/ exit();" in it (not many do), then your lint doesn't know that exit() never returns. In that case, you have to code your example as: ... exit(0); /*NOTREACHED*/ } Most versions of lint take this comment to mean that it should pretend that it had just processed an unconditional goto. The big disadvantage of NOTREACHED is that lint will only tell you something useful if you use it correctly, rather than if you forget to use it (e.g. exit(0); x=5; return x;). The disadvantage of NOTREACHED and GOTO is that the compiler can't recognize them and use the knowledge to optimize the code. Overloading a keyword, as in "extern goto exit();" in a header file would be an ideal solution, but as you can probably guess: that's not C.