Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: Value, value, who's got the value? Message-ID: <10149@smoke.BRL.MIL> Date: 27 Apr 89 12:45:28 GMT References: <1044@itivax.iti.org> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 26 In article <1044@itivax.iti.org> scs@vax3.iti.org (Steve Simmons) writes: >int func2() >{ > int c = 3 ; > c ; >} >Several questions: why does the OS make a difference; why does >System V get it 'right' (even tho the code is wrong); why do >none of these flag func2 as having a syntax error? The function value was whatever was accidentally in the return register. This is yet another case of fortuitous accidents and lack of diagnostic ability in the compiler. In this case, the error is in not returning a value for the function; because of long historical practice before "void" was introduced, int-valued functions in old code are often used like we would currently use void-valued functions. Therefore the compiler deliberately is silent about such an error. However, there is no syntax error; "c;" is a valid albeit useless statement. Why are you posting these bugs, anyway?