Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site bbncca.ARPA Path: utzoo!watmath!clyde!floyd!harpo!eagle!mit-vax!grkermit!genrad!decvax!bbncca!keesan From: keesan@bbncca.ARPA (Morris Keesan) Newsgroups: net.lang.c Subject: expr ? ptr : 0 Message-ID: <547@bbncca.ARPA> Date: Mon, 6-Feb-84 19:53:30 EST Article-I.D.: bbncca.547 Posted: Mon Feb 6 19:53:30 1984 Date-Received: Thu, 9-Feb-84 04:00:46 EST Organization: Bolt, Beranek and Newman, Cambridge, Ma. Lines: 24 ---------------------- Thanks to all who responded to my query. Please stop sending results. For those who missed the question, I will recap. It turns out that the most recent (previous to myself) maintainer of BBN's C compiler put in some code to issue warnings about illegal combinations of pointers and integers. The ?: operator fell into the default case, where the ':' cannot have a pointer and an integer as operands. Unfortunately, he forgot the case where the integer is the constant 0, which is explicitly allowed (Ref. Manual 7.13). Wondering what could be considered "the constant 0", I requested reports on the behaviour of other C compilers when compiling expressions where the 0 in the above (in the Subject) expression was replaced with '\0', 0L, and (short)0. I got several responses about a few compilers for the VAX, all of which accepted '\0' (which, it was pointed out, is actually an integer -- ref.man. 7.1), 0, and 0L, and complained about (short)0. Other responses were of compilers which were silent, such as the V7 PDP-11 compiler, which mine is based on. Reading section 7.1 of the reference manual, one discovers that (short)0 is not, by definition, a "constant": "A constant . . . may be int, long, or double . . . Character constants have type int;" I have decided to allow '\0', 0, and 0L, for consistency with System V and 4.xBSD. Thanks to all who helped out with research. -- Morris M. Keesan {decvax,linus,wjh12}!bbncca!keesan keesan @ BBN-UNIX.ARPA