Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!zephyr.ens.tek.com!tekcrl!tekgvs!toma From: toma@tekgvs.LABS.TEK.COM (Tom Almy) Newsgroups: comp.sys.ibm.pc Subject: Re: Spurious Turbo-C warning -- how do I get around it? Keywords: Turbo-C warning Message-ID: <5939@tekgvs.LABS.TEK.COM> Date: 15 Sep 89 14:11:57 GMT References: <5554@videovax.tv.Tek.com> Reply-To: toma@tekgvs.LABS.TEK.COM (Tom Almy) Distribution: usa Organization: Tektronix, Inc., Beaverton, OR. Lines: 51 In article <5554@videovax.tv.Tek.com> dougs@videovax.tv.Tek.com (Doug Stevens) writes: >I'm trying to figure out how to get around a 'feature' of Turbo-C. >I like to run makes with all the warnings and errors on, but when I >compile a module with this type of structure (vastly simplified to >show the point): > #define TRUE 1 > int test(void) > { > while (TRUE) { > return(1); > } > } >I get this warning: > tcc -w -S test.c > Warning test.c 8: Function should return a value in function test I tried it and got no warning. Are you using Turbo-C 2.0? But I have seen this error with other compilers (in particular, Metaware High-C). >I can get around it by adding a dummy return statement after the loop: [...] > return(1); > } > return(1); > } >But then, this SHOULD generate a warning about unreachable code. It also >wastes code space. A check shows no unreachable code message. Yet no code was generated for the return. >Anyone figured out a way around this? Well, this will work: #define TRUE 1 int test(void) { while (TRUE) { break; } return(1); } Tom Almy toma@tekgvs.labs.tek.com Standard Disclaimers Apply