digitalmars.D.bugs - std.string.replaceSlice() causes a 'Access Violation Error'
- David L. Davis (26/26) May 30 2005 # // replaceSlice() causes a "Access Violation Error"
- Derek Parnell (22/36) May 30 2005 This function must work with a *slice* of the first string parameter and
- David L. Davis (8/44) May 30 2005 Thanks for the reply Derek, and for pointing out my mistake with a clear...
Output: -------- C:\dmd>dmd error1.d C:\dmd\bin\..\..\dm\bin\link.exe error1,,,user32+kernel32/noi; C:\dmd>error1 Error: Access Violation C:\dmd> David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
May 30 2005
On Mon, 30 May 2005 19:53:46 +0000 (UTC), David L. Davis wrote:This function must work with a *slice* of the first string parameter and not just a substring. For example ... char[] ss; int pos; ss = "67"; pos = find(s, ss); if (pos >= 0) sx = replaceSlice(s, s[pos..pos+ss.length], "xxxx") would work. The code for this function is also a poor example of DbC, in that it uses an 'in' block to validate input data. So when the library is compiled in release mode, coders who use the library do not benefit from the validation check. Had the library not been compiled with -release, or the function use the body block to validate input data, you *may* have seen an exception occur. I say 'may', because the validation is not complete anyway, as certain conditions can still get through it. -- Derek Parnell Melbourne, Australia 31/05/2005 7:08:04 AM
May 30 2005
In article <deh3vcn8a47t$.l93c6iajf2pf.dlg 40tude.net>, Derek Parnell says...On Mon, 30 May 2005 19:53:46 +0000 (UTC), David L. Davis wrote:Thanks for the reply Derek, and for pointing out my mistake with a clear sample. :) David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.htmlThis function must work with a *slice* of the first string parameter and not just a substring. For example ... char[] ss; int pos; ss = "67"; pos = find(s, ss); if (pos >= 0) sx = replaceSlice(s, s[pos..pos+ss.length], "xxxx") would work. The code for this function is also a poor example of DbC, in that it uses an 'in' block to validate input data. So when the library is compiled in release mode, coders who use the library do not benefit from the validation check. Had the library not been compiled with -release, or the function use the body block to validate input data, you *may* have seen an exception occur. I say 'may', because the validation is not complete anyway, as certain conditions can still get through it. -- Derek Parnell Melbourne, Australia 31/05/2005 7:08:04 AM
May 30 2005