Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!oliveb!amdahl!rtech!daveb From: daveb@rtech.UUCP (Dave Brower) Newsgroups: comp.lang.c Subject: Re: NULL pointers as arguments, really condition expressions Message-ID: <801@rtech.UUCP> Date: Mon, 4-May-87 00:08:24 EDT Article-I.D.: rtech.801 Posted: Mon May 4 00:08:24 1987 Date-Received: Tue, 5-May-87 01:26:58 EDT References: <1130@ius2.cs.cmu.edu> <148@nbisos.NBI.COM> <641@gargoyle.UChicago.EDU> <17780@sun.uucp> Reply-To: daveb@rtech.UUCP (Dave Brower) Distribution: na Organization: Relational Technology, Alameda CA Lines: 32 In article <17780@sun.uucp> guy%gorodish@Sun.COM (Guy Harris) writes: >This means that if "cp" is of type "char *", then the expression > > 0 ? cp : 0 > >has "the type of the pointer", namely "char *", while if "sxp" is of >type "struct x *", the expression > > 0 ? sxp : 0 > >has the type "struct x *". Both expressions yield null pointers, and >both expressions have different types. Which reminds me of a general problem with the conditional operator. What is the type of the result of evaluating: (expr) ? (double) x : (char)y I believe it is undefined. One could adopt a number of possible rules for interpretation: * Take the type of the true expression as the type of the whole. * Take the type of the false expression... * Take the type of the lval, if any. * Take the type of the "biggest" type of the true or false expr. * Call it an error. I'm inclined to call it an error. Thoughts, anyone? -dB -- {amdahl, sun, mtxinu, cbosgd}!rtech!daveb daveb@rtech.uucp