From: lwm@bronze.ucs.indiana.edu (Larry Meehan)
Subject: Re: strcat(foo,NULL) core dumps on Ultrix
Date: 12 Jun 91 04:00:43 GMT [thread overview]
Message-ID: <1991Jun12.040043.24091@bronze.ucs.indiana.edu> (raw)
In-Reply-To: 966@sdrc.COM
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)
next prev parent reply other threads:[~1991-06-12 4:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1991-06-11 12:34 strcat(foo,NULL) core dumps on Ultrix Rob Gabbard
1991-06-12 4:00 ` Larry Meehan [this message]
1991-06-12 6:20 ` Norman Diamond
1991-06-12 21:41 ` Larry Meehan
1991-06-13 7:20 ` Norman Diamond
1991-06-12 4:12 ` Norman Diamond
1991-06-12 4:34 ` George Robbins
1991-06-12 17:05 ` Lance Franklin
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox