Path: utzoo!attcan!utgpu!watmath!iuvax!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: <19108@mimsy.UUCP> Date: 16 Aug 89 12:57:19 GMT References: <1043@levels.sait.edu.au> <828@ruso.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 16 In article <828@ruso.UUCP> wolfgang@ruso.UUCP (Wolfgang Deifel) writes: >I think it's a difference if you write " NULL + 1 " ( which is non- >portable C, NULL is a machine dependent macro ) and " strchr(...) + 1 ". There is a difference. However: >strchr() is a function that returns always a legal value. If strchr fails >it will return (char*)0 ( regardless of the machine or the compiler ), >and here it's legal to add '1' ( the result is (char*)1 ). this is what we just got finished saying is false: it is NOT legal to add 1 to (char *)0; indeed, it is not legal to add 1 to any of the various infinite varieties of nil pointer. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris