From: ai26 AT sternwarte DOT uni-erlangen DOT de (Michael Lemke, Sternwarte Bamberg, Phone: +49-951-9522216) Subject: RE: strlen on NULL, final test 15 May 1998 15:00:35 -0700 Message-ID: <009C62C2.6ED0BF6E.18.cygnus.gnu-win32@sternwarte.uni-erlangen.de> To: GNU-WIN32%CYGNUS DOT COM AT bamp01 DOT sternwarte DOT uni-erlangen DOT de Cc: ai26 AT sternwarte DOT uni-erlangen DOT de X-Unparseable-Date: Thu, 14 May 1998 13:12:38 MET-1MET DST In a message of Wed, 13 May 1998 10:37:34 -0400 (EDT) Received on Thu, 14 May 1998 11:52:22 MET-1MET DST Ron G. Minnich wrote to gnu-win32 AT cygnus DOT com >to finish this off once and for all, someone raised the question of a >strlen that might test the argument to see if it's equal to 0, and then >return 0. > >First, the empty string and the null string are different, and length of >a null string has no meaning. >Second, if you have null pointers, as others say, fix your code. > >But, even though it's a bad idea, who knows: someone might do it. > >bash$ cat test.c >main() >{ > (void) strlen((char *) 0); >} > >bash$ cc test.c >bash$ ./a.out >Segmentation fault (core dumped) >bash$ > >Again: linux, freebsd, sunos, solaris. > Another data point: LUCKY> cc x (void) strlen((char *) 0); ..........^ %CC-I-IMPLICITFUNC, In this statement, the identifier "strlen" is implicitly dec lared as a function. at line number 3 in file TMP:[AI26]X.C;1 LUCKY> link x LUCKY> run x %SYSTEM-F-ACCVIO, access violation, reason mask=00, virtual address=000000000000 0000, PC=FFFFFFFF8050E8E8, PS=0000001B %TRACE-F-TRACEBACK, symbolic stack dump follows image module routine line rel PC abs PC 0 0000000000000000 FFFFFFFF8050E8E8 X X main 3 00000000000000C8 00000000000200C8 X X __main 0 0000000000000070 0000000000020070 0 FFFFFFFF827530F8 FFFFFFFF827530F8 LUCKY> sh sys/noproc/fu OpenVMS V7.1-1H1 on node LUCKY 14-MAY-1998 13:03:52.43 Uptime 1 01:31:06 Digital AlphaPC 164 500 MHz LUCKY> cc/vers DEC C V5.7-004 on OpenVMS Alpha V7.1-1H1 -- Michael Lemke Sternwarte Bamberg, University of Erlangen-Nürnberg, Germany (lemke AT sternwarte DOT uni-erlangen DOT de or michael AT astro DOT as DOT utexas DOT edu) - 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".