Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!necntc!frog!john From: john@frog.UUCP (John Woods, Software) Newsgroups: comp.lang.c Subject: Re: strcpy wars, jeez! A proposed resolution. Message-ID: <2157@frog.UUCP> Date: 1 Apr 88 22:46:00 GMT References: <7712@apple.Apple.Com> <7485@brl-smoke.ARPA> <10731@mimsy.UUCP> <3267@haddock.ISC.COM> Organization: Superfrog Heaven [ CRDS, Framingham MA ] Lines: 36 In article <3267@haddock.ISC.COM>, karl@haddock.ISC.COM (Karl Heuer) writes: >In article <4215@ihlpf.ATT.COM> nevin1@ihlpf.UUCP (00704a-Liber,N.J.) writes: >>In article <6286@dhw68k.cts.com> david@dhw68k.cts.com (David H. Wolfskill) writes: >>>The current dpANS also specifies "If copying takes place between objects >>>that overlap, the behavior is undefined." I would feel rather more >>>comfortable with changing that to read "... implementation defined." >>I would not! This would imply that a program which calls strcpy() with >>overlapping strings is 'correct', and this is simply not true. > But it would be true, if the standard were to explicitly allow it....if the > "implementation-defined" part is properly phrased, strcpy(s,s+1) would be > guaranteed to be safe. Still no. The problem with "implementation-defined" is that there are no constraints upon what the implementation may define the behavior to be. If you port your program to an implementation where, in 3-point italic type in a margin somewhere, they mention that strcpy(s,s+1) causes the CPU chip to be launched upward with a velocity of 16 km/s, they will be _right._ From the August 3, 1987 draft (and I assume this hasn't changed): "1.7 COMPLIANCE A _strictly conforming program_ shall use only those features of the language and library specified in this standard. It shall not produce output dependent on any unspecified, undefined, or ---> implementation-defined <--- behavior..." ( ---> Emphasis <--- added). If you know that your implementation does what you want with strcpy(s,s+1), then your are free to use it. Your program won't be "strictly conforming", but you may not care about that. Just don't complain when you hear that "chuffBANG!" of the CPU chip being launched when you buy that shiny new Mark IV Datablaster... -- John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101 ...!decvax!frog!john, ...!mit-eddie!jfw, jfw@eddie.mit.edu FUN: THE FINAL FRONTIER Zippy the Pinhead in '88!