[ 
https://issues.apache.org/jira/browse/STDCXX-170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Travis Vitek updated STDCXX-170:
--------------------------------

    Attachment: stdcxx-170-1.patch

Attaching patch for review.

The patch {{stdcxx-170.patch}} is suitable for 4.2.2. If the range being copied 
from is a pointer type and overlaps or IterType is not a pointer type, then we 
make a copy of the source range and then replace using the temporary.

I could create an additional patch that would allow us to avoid creating 
unnecessary copies of the src range when the iterators are 
std::string::iterator or std::string::const_iterator types. This would only 
provide a benefit in debug builds, so I don't see it as being extremely useful.

> std::string::replace (iterator, iterator, InputIterator, InputIterator) 
> inserting self incorrect
> ------------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-170
>                 URL: https://issues.apache.org/jira/browse/STDCXX-170
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.3, 4.1.4, 4.2.0
>         Environment: all
>            Reporter: Anton Pevtsov
>            Assignee: Travis Vitek
>            Priority: Minor
>             Fix For: 4.3
>
>         Attachments: 21.string.replace.stdcxx-170.cpp, stdcxx-170-1.patch, 
> string.cc.diff
>
>   Original Estimate: 8h
>          Time Spent: 16h
>  Remaining Estimate: 0h
>
> This test fails:
> #include <iostream>
> #include <string>
> static const char* test = "babc";
> int main (void)
> {
>     std::string s ("abc");
>     s.replace (s.begin (), s.begin (), s.begin () + 1, s.begin () + 2);
>     std::cout << "Expected " << test << " and got " << s << '\n';
>     return 0;
> }
> The output is "Expected babc and got aabc".
> See details here:
> http://mail-archives.apache.org/mod_mbox/incubator-stdcxx-dev/200604.mbox/[EMAIL
>  PROTECTED]

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to