From: diamond@jit533.swstokyo.dec.com (Norman Diamond)
Subject: Re: strcat(foo,NULL) core dumps on Ultrix
Date: 12 Jun 91 04:12:30 GMT [thread overview]
Message-ID: <1991Jun12.041230.12264@tkou02.enet.dec.com> (raw)
In-Reply-To: 966@sdrc.COM
In article <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. Why would anyone want to do this anyway ? How about....
> strcat(foo,getenv("FOO"))
> instead of
> if (getenv("FOO")) strcat(foo,getenv("FOO"));
The behavior is undefined according to the C standard. Core dumps are
a common result (although they used to be less common when one particular
hardware architecture used to be more common).
If you want to change the C language (including the standard library), wait
for the ANSI committee to begin preparing the next revision of the language,
and make your suggestions to them. It probably won't be a long wait;
proceedings for the 1989 standard began around 8 years ago. They have
probably heard this one before, so you will probably have to get a lot
of people on your side to join the committee and vote for your proposal.
>Actually, just coding strcat(foo,NULL) will dump. Anyone run into this ?
Yes. Mostly new programmers, and also some irresponsible (i.e. experienced
enough to know better, but lazy -- they know who they are) ones.
>Am I doing a no-no here.
Yes.
--
Norman Diamond diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Permission is granted to feel this signature, but not to look at it.
next prev parent reply other threads:[~1991-06-12 4:12 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
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 [this message]
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