C Compiler bug (and fix for a different one)
Joseph S. D. Yao
jsdy at hadron.UUCP
Thu Jul 31 15:35:20 AEST 1986
In article <461 at watmath.UUCP> rbutterworth at watmath.UUCP (Ray Butterworth) 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.
>If I'm not throwing them away, what is it you think I'm doing with them?
>Also, the proposed ANSI draft explicitly states that the second and third
>operands of ?: may each have (void) type, so I'm not trying anything
>unusual here.
My 1984 version of X3J11 (has it been that long?) agrees with K&R
that each of the operands must have a value. This makes intuitive
sense. The meaning of X ? Y : Z is: an expression whose value is
the value of Y, if the value of X is non-zero; otherwise, the value
of Z. By this, all three must evaluate to some value.
Do you have a more recent edition of X3J11 that r e a l l y lets
voids in there? Ugh! (What date?) Besides which, all C compilers
until just recently (Lattice, Microsoft) had been written to K&R
and v7-s3-s5, not to the ANSI standard.
--
Joe Yao hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}
jsdy at hadron.COM (not yet domainised)
More information about the Comp.lang.c
mailing list