Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!brl-smoke!smoke!lcc.jbrown@LOCUS.UCLA.EDU From: lcc.jbrown@LOCUS.UCLA.EDU (Jordan Brown) Newsgroups: net.unix Subject: if (pointer) command Message-ID: <3651@brl-smoke.ARPA> Date: Mon, 8-Sep-86 21:40:30 EDT Article-I.D.: brl-smok.3651 Posted: Mon Sep 8 21:40:30 1986 Date-Received: Tue, 9-Sep-86 06:27:09 EDT Sender: news@brl-smoke.ARPA Lines: 17 > From: Brandon Allbery > [ code which used "if(pointer) stmt;" ] > But if a pointer is 4 bits and an int is 2 bits (some 68000 implementations), > you'll get spurious failures if the pointer returned by malloc is a multiple > of 0x10000! Those are the smallest pointers and ints I've ever seen! But seriously, K&R never says that the expression in an if is converted to an int. It says (pg 201) ...the expression is evaluated and it if is non-zero... While this does not explicitly allow the if(pointer) usage, it can easily be interpreted to mean that "if(expr)" is equivalent to "if(expr!=0)", which IS guaranteed to work for pointers (pg 190). Lots of code would break if this usage was not allowed.