Xref: utzoo comp.lang.c:8370 comp.unix.questions:6149 Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c,comp.unix.questions Subject: Re: BSD C compiler bug Message-ID: <10747@mimsy.UUCP> Date: 21 Mar 88 07:48:16 GMT References: <570@mtxinu.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 40 In article <570@mtxinu.UUCP> tim@mtxinu.UUCP (Tim Wood) writes: >#define NULL 0 ... > unsigned char **foo; > > foo = NULL; > foo = (NULL, NULL); > foo = ( !foo ? NULL : (fn(2), NULL) ); [produces] >"comma.c", line 8: warning: illegal combination of pointer and integer, op = >"comma.c", line 9: warning: illegal combination of pointer and integer, op = >K&R say that the result type & value of a comma expression are that of the >second term, which is NULL (0) in all cases here. And [0] is assignment >compatible to all pointers. I am not convinced it is a bug. `The integer constant 0' can be assigned to any pointer; the question is whether the result of a complex expression can be considered an `integer constant'. The 11 Jan 1988 draft of the dpANS has this to say about constant expressions (p. 56): CONSTRAINTS Constant expressions shall not contain assignment, increment, decrement, function-call, or comma operators, except when they are contained within the operand of a |sizeof| operator. That disallows the second expression (foo = (NULL, NULL)) explicitly, and the third because of the function call; it does not disallow foo = 1 ? NULL : NULL; but the latest pcc seems to allow this anyway. I do think prohibiting comma expressions in constants is unnecessary. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris