Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!itivax!vax3.iti.org!scs From: scs@vax3.iti.org (Steve Simmons) Newsgroups: comp.lang.c Subject: Value, value, who's got the value? Summary: Why no syntax error? Message-ID: <1044@itivax.iti.org> Date: 27 Apr 89 04:48:55 GMT Sender: news@itivax.iti.org Reply-To: scs@vax3.iti.org (Steve Simmons) Organization: Industrial Technology Institute Lines: 45 Consider the following program: int func1() { int b ; b = 2 ; } int func2() { int c = 3 ; c ; } main() { int a = 1 ; printf( "Value of a is %d\n", a ) ; a = func1() ; printf( "Value of a is %d\n", a ) ; a = func2() ; printf( "Value of a is %d\n", a ) ; } Compile and run this on a UNIX-PC (system V) under standard cc or with gcc, and the result is: Value of a is 1 Value of a is 2 Value of a is 3 On BSD43. with standard cc or gcc, the result is Value of a is 1 Value of a is 0 Value of a is 0 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? Steve Simmons Just another midwestern boy scs@vax3.iti.org -- or -- ...!sharkey!itivax!scs "Hey...you *can* get here from here!"