Mail Archives: cygwin/1998/05/13/23:25:49
>nonsense. if strlen() doesn't crash when given a null pointer, the only
>reason is that the implementation must contain a test for the null
>pointer. this is atypical. strlen(NULL) normally crashes on unix. unix
>core files may start at address zero, but zero is an illegal address.
>this is deliberate. using null pointers is so common an error in c
>programming, that the null address was deemed to always be invalid.
>remember that c and unix were invented together.
There is a difference between a null pointer and zero as an address. On
some machines, the null pointer is actually a non-zero number, though
still represented in C as "0". Read the C FAQ for more details.
Whatever the correct behaviour is, it's obvious that different systems
do different things, and hence strlen(0) is worth avoiding. Certainly
this isn't a bug in cygwin.
--
Ed Avis <http://members.tripod.com/~mave>
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -