strcpy wars, jeez! A proposed resolution.

David H. Wolfskill david at dhw68k.cts.com
Tue Mar 29 03:16:54 AEST 1988


As many have pointed out, there is an expectation that strcpy() will
copy characters from left to right, terminating the copy when the
terminating NUL is copied.

Recalling that the dpANS specifies "... the behavior of an abstract
machine in which the issues of optimization are irrelevant," it would
seem to make some sense to modify the specification to be similar to the
above.

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."

This may arguably be a "quality of implementation" issue; I prefer to
think of it as a "quality of standard" issue.

(Oh: I do know of one machine in which fields in main storage are
addressed on the right -- for almost all instructions -- but I don't
know of a C compiler for it, and I consider its architecture (for this
reason, as well as others) to be sufficiently pathological that it's not
worth considering important.  I just wish my employer hadn't purchased
so many of the brain-damaged things!)

david
-- 
David H. Wolfskill
uucp: ...{trwrb,hplabs}!felix!dhw68k!david	InterNet: david at dhw68k.cts.com



More information about the Comp.lang.c mailing list