"do ... while ((NULL + 1) - 1);" -- valid C?
Chris Torek
chris at mimsy.UUCP
Wed Aug 16 22:57:19 AEST 1989
In article <828 at ruso.UUCP> wolfgang at 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 at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list