Article View: comp.sys.dec
Article #4088Re: strcat(foo,NULL) core dumps on Ultrix
From: Norman Diamond
Date: Wed, 12 Jun 1991 04:12
Date: Wed, 12 Jun 1991 04:12
30 lines
2028 bytes
2028 bytes
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.
Technical Details
Message-ID:
<1991Jun12.041230.12264@tkou02.enet.dec.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamondReferences:
<966@sdrc.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamond From: diamond@jit533.swstokyo.dec.com (Norman Diamond) Newsgroups: comp.sys.dec Subject: Re: strcat(foo,NULL) core dumps on Ultrix Keywords: dec c strcat Message-ID: <1991Jun12.041230.12264@tkou02.enet.dec.com> Date: 12 Jun 91 04:12:30 GMT References: <966@sdrc.COM> Sender: usenet@tkou02.enet.dec.com (USENET News System) Reply-To: diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 30