Path: utzoo!attcan!uunet!lll-winken!ames!xanth!mcnc!thorin!ra!poirier From: poirier@ra.cs.unc.edu (Dan Poirier) Newsgroups: comp.sys.ibm.pc Subject: Bug in TC 2.0 strrchr()? Keywords: Turbo-C bug strrchr pointers Message-ID: <6371@thorin.cs.unc.edu> Date: 26 Jan 89 14:53:17 GMT Sender: news@thorin.cs.unc.edu Lines: 22 Last night I discovered what I consider a bug in Turbo-C's strrchr() function. It searches a string back to front for a character. In the large model, if the string happens to begin at an offset of 0, the search does not terminate properly due to pointer wrap-around (e.g., the pointer wraps from 0000 to FFFF and the termination test does not work). I know the manuals warn about this kind of problem in user-written code, but it seems to me that Turbo-C's libraries should handle it properly, and not fail just because a string variable happened to fall at a particular offset. Am I wrong? Is there something I could/should have done to avoid this kind of problem? Thanks for any advice. _dan P.S. Turbo Debugger was quite helpful in tracking this down, even though I had not used it before. -------------------------------------------------------- Dan Poirier UNC Chapel Hill poirier@cs.unc.edu Disclaimer: I saw it on the radio. --------------------------------------------------------