Path: utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!bloom-beacon!oberon!cit-vax!tim From: tim@cit-vax.Caltech.Edu (Timothy L. Kay) Newsgroups: comp.sys.ibm.pc Subject: bug in Turbo C 1.5 Message-ID: <5298@cit-vax.Caltech.Edu> Date: 23 Jan 88 23:10:36 GMT Reply-To: tim@cit-vax.UUCP (Timothy L. Kay) Organization: California Institute of Technology Lines: 69 To the best of my recollection, I don't recall having seen any bug reports so far for Turbo C 1.5. Am I the first person to report a bug in Turbo C 1.5? This program ---------------------------------- #include void main() { char *s = "this is a test"; printf("%s\n", s); memcpy(s + 1, s, strlen(s) - 1); printf("%s\n", s); } ---------------------------------- displays -------------- this is a test tthis is a tes -------------- under Turbo C 1.0, and -------------- this is a test tthhssii ee -------------- under Turbo C 1.5. The Turbo C 1.0 memcpy() detects if the source and destination overlap and switches the direction of the copying. Borland must have decided that the memcpy() routine should not be so smart. The Turbo C 1.5 memcpy() generates the above (rather peculiar) pattern by doing word-at-a-time copying, always in the positive direction. To see how the pattern was generated, we should look at the copy one word at a time. The ^^ marks the word to be moved. The destination of the move is marked by the second ^. -------------- this is a test ^^ tths is a test ^^ tthhsis a test ^^ tthhssi a test ^^ tthhssii test ^^ tthhssii est ^^ tthhssii et ^^ tthhssii ee -------------- I have worked around this bug by extracting the old version out of the old library. tlib /C \tc10\lib\ch.lib *memcpy.obj Then I added "memcpy.obj" to my project, and it works. Tim