Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Passing functions in C Message-ID: <16161@haddock.ima.isc.com> Date: 14 Mar 90 00:52:46 GMT References: <1990Mar9.045151.9601@ucselx.sdsu.edu> <3242@hcx1.SSD.CSD.HARRIS.COM> <3243@hcx1.SSD.CSD.HARRIS.COM> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Distribution: usa Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 20 In article <3243@hcx1.SSD.CSD.HARRIS.COM> brad@SSD.CSD.HARRIS.COM (Brad Appleton) writes: >[The function int foo() { int i; i = 10; } will, on some compilers, >appear to have returned the value 10. Unreliable?] Very. What you're actually getting is whatever happened to be left lying around in the function-return-value register. >Should the compiler catch the "missing return" or is that left strictly >to lint? As far as the language definition goes, there is no distinction between cc and lint. This check is traditionally done only in lint because it generally requires cross-module analysis to know whether the value that isn't returned from foo() is actually being used anywhere. If it *isn't* being used, then the code is legal but sloppy (it should be declared "void"). This remains legal for for backward compatibility, and, unfortunately, a lot of code continues to depend on it. Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint