Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!cam-cl!news From: rjb17@ely.cl.cam.ac.uk (Richard Black) Newsgroups: comp.sys.acorn Subject: Re: Languages Message-ID: <1991Feb13.100325.28239@cl.cam.ac.uk> Date: 13 Feb 91 10:03:25 GMT Sender: news@cl.cam.ac.uk (The news facility) Reply-To: rjb17@ely.cl.cam.ac.uk (Richard Black) Lines: 59 In article <1991Feb11.105227.15182@and.cs.liv.ac.uk> rkl@and.cs.liv.ac.uk writes: > I was dabbling in C on our HP UNIX boxes a while back and I was shocked at > the complete lack of warning about the following: > > hello(param1,param2) > int param1,param2; > { > printf("Param 2 = %d\n",param2); > } > > main() > { > hello(1); > } > > Yes folks, I forgot a parameter and THERE WAS NOT EVEN A WARNING FROM THE > COMPILER ! There should not be a warning from the compiler. It is a K&R compiler not an ANSI compiler. Besides which you have deliveratly used a K&R style definition. Even "gcc - Wall -pedantic" gives acorn.c: In function hello: acorn.c:2: warning: return-type defaults to `int' acorn.c:4: warning: implicit declaration of function `printf' acorn.c:5: warning: control reaches end of non-void function acorn.c: In function main: acorn.c:8: warning: return-type defaults to `int' acorn.c:10: warning: control reaches end of non-void function And doesn't warn of the incorrect number of parameters. This is correct K&R behaviour. > I put it through lint too and NO WARNING AGAIN ! Really? Transcript follows... --/Nfs/forties/usr14/rjb17 $ arch hp9000s300 --/Nfs/forties/usr14/rjb17 $ lint acorn.c acorn.c ============== (10) warning: main() returns random value to invocation environment warning: argument unused in function: (2) param1 in hello ============== function called with variable number of arguments hello acorn.c(3) :: acorn.c(9) function returns value which is always ignored printf What did you do, lint > /dev/null or something? R.