Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!cbdkc1!cbnap!whp From: whp@cbnap.UUCP (W. H. Pollock x4575 3S235) Newsgroups: net.lang.c,net.bugs Subject: Re: C Compiler bug (?: operator) Message-ID: <155@cbnap.UUCP> Date: Thu, 31-Jul-86 09:12:59 EDT Article-I.D.: cbnap.155 Posted: Thu Jul 31 09:12:59 1986 Date-Received: Sat, 2-Aug-86 03:33:30 EDT References: <273@watmath.UUCP> <5858@alice.uUCp> <134@sas.UUCP> Reply-To: whp@cbnap.UUCP (W. H. Pollock x4575 3S235) Organization: AT&T Bell Laboratories, Columbus Lines: 40 Xref: watmath net.lang.c:10115 net.bugs:853 Summary: conditional operator semantics (?:) In article <134@sas.UUCP> jcz@sas.UUCP (Carl Zeigler) writes: > > > > void f3(which) > > > { > > > extern void f1(),f2(); > > > which?f1():f2(); > > > } > > > cc(1) gives an "incompatible types" error. > > > > As it should. The only thing you're allowed to do with void values > > is throw them away. > >Scan again, Andrew, the (void) values are being thrown away. The void values are not thrown away! Remember that (A?B:C) is an expression *returning a value*. C is giving the error because it can't determine the type of the return value. This is clearer in the following: void f3(which) { int f1(); void f2(); int foo; ... foo = which?f1():f2(); ... } which results in the same error message, for the same reason. Another example: f4() { ... return ((void) expression); } Note it doesn't mater what use is made of the return value (in the original example it is thrown on the floor, which is what probably confused some people).