You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@stdcxx.apache.org by "Martin Sebor (JIRA)" <ji...@apache.org> on 2008/01/29 06:30:33 UTC

[jira] Commented: (STDCXX-170) std::string::replace (iterator, iterator, InputIterator, InputIterator) inserting self incorrect

    [ https://issues.apache.org/jira/browse/STDCXX-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12563387#action_12563387 ] 

Martin Sebor commented on STDCXX-170:
-------------------------------------

I'm not sure we can introduce a {{string_type}} local typedef into {{<string>}}. Unless there already is a typedef with that name in some scope the name should be private (e.g., {{_C_string_type}}).

{noformat}
@ -476,6 +476,8 @@

     typedef _Alloc                                allocator_type;
     typedef _TYPENAME allocator_type::size_type   size_type;
 
+    typedef _STD::basic_string<_CharT, _Traits, _Alloc> string_type;
{noformat}

Can you explain the {{reinterpret_cast}} in the hunk below?

{noformat}
@@ -638,14 +653,40 @@

         }
         else {
             // Current reference has enough room.
-            if (__rem)  
+            pointer __tmp = 0;
+
+            if (__n2) {
+                const_reference __ref =
+                    _RWSTD_REINTERPRET_CAST (const_reference, *__first2);
+                const const_pointer __ptr =
+                    _RWSTD_VALUE_ALLOC (_C_value_alloc_type, __s,
+                                        address (__ref));
+                if (__s.data () <= __ptr && __s.data () + __ssize > __ptr) {
+                    __tmp = _RWSTD_VALUE_ALLOC (_C_value_alloc_type, __s,
+                                                allocate (__n2));
+                    for (__d = 0; __d < __n2; __d++)
+                        traits_type::assign (*(__tmp + __d), *__first2++);
+                }
+            }
+
+            if (__rem)
{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/%3c44337C76.4020909@roguewave.com%3e

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