Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!csd4.milw.wisc.edu!uxc.cso.uiuc.edu!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: "do ... while ((NULL + 1) - 1);" -- valid C? Message-ID: <18997@mimsy.UUCP> Date: 11 Aug 89 09:14:09 GMT References: <1043@levels.sait.edu.au> <826@ruso.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 21 >> while ((s = strchr(s, ',') + 1) - 1) In article <826@ruso.UUCP> wolfgang@ruso.UUCP (Wolfgang Deifel) writes: >Why should NULL + 1 not be valid ??? NULL is a pointer with the value 0 >and you can add the integer 1 to it .... NULL is not a pointer with the value 0, and 1 is not being added to NULL here, but rather to a nil-pointer-to-char in the case in question. NULL is a preprocessor macro; it expands to either an integral constant zero (whose type is one of the integral types, e.g., int or short or long, and whose value is zero) or to such a value cast to pointer-to-void (whose type is pointer-to-void and whose value is unknowable). A nil-pointer-to-char has type pointer-to-char and an ineffable value. There is no way to talk about its value other than to say `it is a nil pointer to char'. In particular, you cannot say what happens when you add one to it. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris