From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,e1ee64db7e032a4e,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1991-06-13 04:28:43 PST Path: gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!lll-winken!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 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.