[
https://issues.apache.org/jira/browse/STDCXX-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12563464#action_12563464
]
Farid Zaripov commented on STDCXX-170:
--------------------------------------
The *__first2 expression can be of different type than const_reference.
I.e. from the third example (see comment at 27/Apr/06 12:01 AM), the
const_reference is const char&, but *__first2 is unsigned char&.
The allocator<>::address() method accept allocator<>::const_reference type, and
to avoid of making the temporary object of char type, assigned with a result of
*__first2, and passing the reference to this temporary object in address()
method I've used the reinterpret_cast.
The using address() method is not necessary and the following code
{noformat}
const_reference __ref =
_RWSTD_REINTERPRET_CAST (const_reference, *__first2);
const const_pointer __ptr =
_RWSTD_VALUE_ALLOC (_C_value_alloc_type, __s,
address (__ref));
{noformat}
could be replaced to
{noformat}
const const_pointer __ptr =
&_RWSTD_REINTERPRET_CAST (const_reference, *__first2);
{noformat}
> 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: Farid Zaripov
> Priority: Minor
> Fix For: 4.2.1
>
> Attachments: 21.string.replace.stdcxx-170.cpp, string.cc.diff
>
> Original Estimate: 8h
> Time Spent: 10h
> 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.