Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbatt!ihnp4!homxb!houxm!mhuxt!m10ux!mnc From: mnc@m10ux.UUCP Newsgroups: comp.lang.c,comp.unix.wizards Subject: C Compiler Bug (possibly widespread) Message-ID: <203@m10ux.UUCP> Date: Mon, 27-Apr-87 15:56:49 EDT Article-I.D.: m10ux.203 Posted: Mon Apr 27 15:56:49 1987 Date-Received: Sat, 2-May-87 01:47:23 EDT Organization: AT&T Bell Labs, Murray Hill Lines: 23 Keywords: SystemV Sun C Compilers Xref: utgpu comp.lang.c:1919 comp.unix.wizards:1943 Here is a nasty little bug I just ran into with the Sys V R2 (VAX) C compiler and the Sun C compiler (but it does not exist on 4.3 BSD). Consider: extern void f(), (*fp)(); int x; main() { g(x ? f : fp); g(x ? f : *fp); } Both of the uses of the "? :" operator produce the message "operands of : have incompatible types". Changing "void" to any other type makes both error messages go away. Notice that there is no attempt to use a void value in the above expression. Since this code is likely to occur in any C program that passes procedures (i.e. void functions) as arguments, I don't understand how the bug could have persisted this long. The only work-around I can think of (besides changing the declaration of f and fp) is to use "if - else" instead of "? - :". -- Michael Condict {ihnp4|vax135|cuae2}!m10ux!mnc AT&T Bell Labs (201)582-5911 MH 3B-416 Murray Hill, NJ