Path: utzoo!utgpu!water!watmath!clyde!att-cb!att-ih!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704a-Liber) Newsgroups: comp.lang.c Subject: Re: strcpy wars, jeez! A proposed resolution. Message-ID: <4244@ihlpf.ATT.COM> Date: 1 Apr 88 22:42:15 GMT References: <7712@apple.Apple.Com> <7485@brl-smoke.ARPA> <10731@mimsy.UUCP> <7506@brl-smoke.ARPA> <4251@hoptoad.uucp> <6286@dhw68k.cts.com> <4215@ihlpf.ATT.COM> <3267@haddock.ISC.COM> Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 53 In article <3267@haddock.ISC.COM> karl@haddock.ima.isc.com (Karl Heuer) writes: >In article <4215@ihlpf.ATT.COM> nevin1@ihlpf.UUCP (00704a-Liber,N.J.) writes: >>If this were to change, all programs that use strcpy() would be suspect every >>time a new version of the compiler comes out > >Only those programs that use strcpy on overlapping strings. And if the >"implementation-defined" part is properly phrased, strcpy(s,s+1) would be >guaranteed to be safe. First off, just by looking at a program how can I tell whether or not it uses overlapping strings (under your proposal)?? There is no way for me to tell the difference between a program that is using strcpy() in an implementation-DEPENDENT way and a program which can portably use strcpy() (at least not by just looking at it). From a maintenance point of view, this is very undesirable!! Secondly, I do not like the change that would have to be made to the prototype for strcpy. The prototype would change from: char *strcpy(noalias char *s1, const noalias char *s2) to char *strcpy(char *s1, char *s2) since, as you pointed out, both s1 and s2 are possibly aliased and the string pointed to by s2 is no longer guaranteed to be constant (see below). char *foo, *bar; ... /*assume that foo points to string "stuff" in read/write memory*/ bar = foo + 1; strcpy(foo, bar); Under your proposal, this would *legally* change the value of what bar points to (unless you are going to put in some wording about only being able to copy the right half or less of overlapping strings, but this wording is VERY messy)!! I'm sorry, but I like knowing that the source string should not be changed by strcpy() in a conforming program!! In article <3266@haddock.ISC.COM> karl@haddock.ima.isc.com (Karl Heuer) writes: >I don't see that such a compiler would have to depend on the implementation; >just on the functional specification (which has now been standardized). MAKE UP YOUR MIND!! You either want to have programs which are dependent on the implementation of the libraries or you don't. I don't really care which of these two views that you take, JUST BE CONSISTENT!! -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_