Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!news.cs.indiana.edu!bronze!lwm From: lwm@bronze.ucs.indiana.edu (Larry Meehan) Newsgroups: comp.sys.dec Subject: Re: strcat(foo,NULL) core dumps on Ultrix Keywords: null NULL Message-ID: <1991Jun12.040043.24091@bronze.ucs.indiana.edu> Date: 12 Jun 91 04:00:43 GMT Article-I.D.: bronze.1991Jun12.040043.24091 References: <966@sdrc.COM> Organization: Indiana University Lines: 37 In <966@sdrc.COM> wggabb@sdrc.COM (Rob Gabbard) writes: >A call to strcat with NULL as the second argument core dumps with a memory >fault on Ultrix. ... >Actually, just coding strcat(foo,NULL) will dump. Anyone run into this ? >Am I doing a no-no here. You must be on one of the MIPS-based DEC systems. Due to a quirk of the VAX port of ULTRIX, you can get by with what you are trying to do, but you are, strictly speaking, doing a no-no. The thing to remember is that NULL is not the same thing as "", since strcat(foo,"") will work just fine. This program will fail too for *exactly* the same reason: main() { char *p, c; p = (char *) 0; c = *p; } If you look in /usr/include/stdio.h, you will see that NULL is really just 0, so our programs are trying to access location 0 which is legal on a VAX, but not on the MIPS implementation of Ultrix. A lot of "bug-free" code broke when it was moved from VAX to non-VAX systems. The little program above dumps core on a MIPS CPU and runs without errors on a VAX. The program is at fault, not Ultrix. Hope this helps. -- Larry Meehan University Computing Services lwm@ucs.indiana.edu Indiana University ("Industry without art is brutality." -- Ananda Coomaraswamy) -- Larry Meehan University Computing Services lwm@ucs.indiana.edu Indiana University ("Industry without art is brutality." -- Ananda Coomaraswamy)