You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Martin Sebor (JIRA)" <ji...@apache.org> on 2005/09/14 20:30:55 UTC

[jira] Created: (STDCXX-25) string::insert() curruption inserting self

string::insert() curruption inserting self
------------------------------------------

         Key: STDCXX-25
         URL: http://issues.apache.org/jira/browse/STDCXX-25
     Project: STDCXX
        Type: Bug
  Components: 21. Strings  
    Versions: 4.1.2    
 Environment: All
    Reporter: Martin Sebor
 Assigned to: Martin Sebor 
     Fix For: 4.1.3


The program below aborts. According to 21.3.5.4, p16 of C++ '03, the effects of the insert member function template are "Equivalent to insert(p - begin(), basic_string(first, last))." See also http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#7.

$ cat t.cpp && nice gmake SRCS=t.cpp && ./t
#include <cassert>
#include <string>

int main ()
{
     std::string s ("ab");

     s.insert (s.begin () + 1, s.data (), s.data () + s.length ());

     assert ("aabb" == s);
}
aCC -c  -D_RWSTDDEBUG  -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/../../aCC-6.0-11s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include  -AA -g +d   +w +W392 +W655 +W684 +W818 +W819 +W849 +W2193 +W2236 +W2261 +W2340 +W2401 +W2487  t.cpp 
aCC t.o -o t -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/rwtest -lrwtest -AA +nostl -Wl,+s -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib    -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib -lstd   -lm  
Assertion failed: "aabb" == s, file t.cpp, line 10
ABORT instruction (core dumped)


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (STDCXX-25) string::insert() curruption inserting self

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/STDCXX-25?page=comments#action_12329450 ] 

Martin Sebor commented on STDCXX-25:
------------------------------------

See also:
http://mail-archives.apache.org/mod_mbox/incubator-stdcxx-dev/200509.mbox/%3c4FA4B7B3231C5D459E7BAD020213A9420301B1B7@bco-exchange.bco.roguewave.com%3e

> string::insert() curruption inserting self
> ------------------------------------------
>
>          Key: STDCXX-25
>          URL: http://issues.apache.org/jira/browse/STDCXX-25
>      Project: STDCXX
>         Type: Bug
>   Components: 21. Strings
>     Versions: 4.1.2
>  Environment: All
>     Reporter: Martin Sebor
>     Assignee: Martin Sebor
>      Fix For: 4.1.3

>
> The program below aborts. According to 21.3.5.4, p16 of C++ '03, the effects of the insert member function template are "Equivalent to insert(p - begin(), basic_string(first, last))." See also http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#7.
> $ cat t.cpp && nice gmake SRCS=t.cpp && ./t
> #include <cassert>
> #include <string>
> int main ()
> {
>      std::string s ("ab");
>      s.insert (s.begin () + 1, s.data (), s.data () + s.length ());
>      assert ("aabb" == s);
> }
> aCC -c  -D_RWSTDDEBUG  -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/../../aCC-6.0-11s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include  -AA -g +d   +w +W392 +W655 +W684 +W818 +W819 +W849 +W2193 +W2236 +W2261 +W2340 +W2401 +W2487  t.cpp 
> aCC t.o -o t -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/rwtest -lrwtest -AA +nostl -Wl,+s -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib    -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib -lstd   -lm  
> Assertion failed: "aabb" == s, file t.cpp, line 10
> ABORT instruction (core dumped)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (STDCXX-25) string::insert() curruption inserting self

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/STDCXX-25?page=all ]
     
Martin Sebor resolved STDCXX-25:
--------------------------------

    Resolution: Fixed

Test passes. Closed.

> string::insert() curruption inserting self
> ------------------------------------------
>
>          Key: STDCXX-25
>          URL: http://issues.apache.org/jira/browse/STDCXX-25
>      Project: STDCXX
>         Type: Bug
>   Components: 21. Strings
>     Versions: 4.1.2
>  Environment: All
>     Reporter: Martin Sebor
>     Assignee: Martin Sebor
>      Fix For: 4.1.3
>  Attachments: stdcxx-25.patch
>
> The program below aborts. According to 21.3.5.4, p16 of C++ '03, the effects of the insert member function template are "Equivalent to insert(p - begin(), basic_string(first, last))." See also http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#7.
> $ cat t.cpp && nice gmake SRCS=t.cpp && ./t
> #include <cassert>
> #include <string>
> int main ()
> {
>      std::string s ("ab");
>      s.insert (s.begin () + 1, s.data (), s.data () + s.length ());
>      assert ("aabb" == s);
> }
> aCC -c  -D_RWSTDDEBUG  -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/../../aCC-6.0-11s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include  -AA -g +d   +w +W392 +W655 +W684 +W818 +W819 +W849 +W2193 +W2236 +W2261 +W2340 +W2401 +W2487  t.cpp 
> aCC t.o -o t -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/rwtest -lrwtest -AA +nostl -Wl,+s -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib    -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib -lstd   -lm  
> Assertion failed: "aabb" == s, file t.cpp, line 10
> ABORT instruction (core dumped)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (STDCXX-25) string::insert() curruption inserting self

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/STDCXX-25?page=all ]
     
Martin Sebor closed STDCXX-25:
------------------------------


Fix confirmed.

> string::insert() curruption inserting self
> ------------------------------------------
>
>          Key: STDCXX-25
>          URL: http://issues.apache.org/jira/browse/STDCXX-25
>      Project: STDCXX
>         Type: Bug
>   Components: 21. Strings
>     Versions: 4.1.2
>  Environment: All
>     Reporter: Martin Sebor
>     Assignee: Martin Sebor
>      Fix For: 4.1.3
>  Attachments: stdcxx-25.patch
>
> The program below aborts. According to 21.3.5.4, p16 of C++ '03, the effects of the insert member function template are "Equivalent to insert(p - begin(), basic_string(first, last))." See also http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#7.
> $ cat t.cpp && nice gmake SRCS=t.cpp && ./t
> #include <cassert>
> #include <string>
> int main ()
> {
>      std::string s ("ab");
>      s.insert (s.begin () + 1, s.data (), s.data () + s.length ());
>      assert ("aabb" == s);
> }
> aCC -c  -D_RWSTDDEBUG  -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/../../aCC-6.0-11s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include  -AA -g +d   +w +W392 +W655 +W684 +W818 +W819 +W849 +W2193 +W2236 +W2261 +W2340 +W2401 +W2487  t.cpp 
> aCC t.o -o t -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/rwtest -lrwtest -AA +nostl -Wl,+s -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib    -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib -lstd   -lm  
> Assertion failed: "aabb" == s, file t.cpp, line 10
> ABORT instruction (core dumped)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (STDCXX-25) string::insert() curruption inserting self

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/STDCXX-25?page=comments#action_12329375 ] 

Martin Sebor commented on STDCXX-25:
------------------------------------

See the failures in 21.string.insert.cpp:

$ ./21.string.insert --severity=7
# ASSERTION (S7) (4 lines):
# TEXT: basic_string<char>::insert (iterator, const_pointer, const_pointer) expected "aabb", got "aaab"
# CLAUSE: lib.string.insert
# LINE: 190

# ASSERTION (S7) (4 lines):
# TEXT: basic_string<char>::insert (iterator, const_pointer, const_pointer) expected "baabb", got "aaaab"
# CLAUSE: lib.string.insert
# LINE: 200

# ASSERTION (S7) (4 lines):
# TEXT: basic_string<wchar_t>::insert (iterator, const_pointer, const_pointer) expected "aabb", got L"aaab"
# CLAUSE: lib.string.insert
# LINE: 190

# ASSERTION (S7) (4 lines):
# TEXT: basic_string<wchar_t>::insert (iterator, const_pointer, const_pointer) expected "baabb", got L"aaaab"
# CLAUSE: lib.string.insert
# LINE: 200

# +-----------------------+--------+--------+--------+
# | DIAGNOSTIC            | ACTIVE |  TOTAL |   PASS |
# +-----------------------+--------+--------+--------+
# | (S1) INFO             |     25 |     25 |     0% |
# | (S5) WARNING          |      6 |      6 |     0% |
# | (S7) ASSERTION        |      4 |     70 |    94% |
# +-----------------------+--------+--------+--------+


> string::insert() curruption inserting self
> ------------------------------------------
>
>          Key: STDCXX-25
>          URL: http://issues.apache.org/jira/browse/STDCXX-25
>      Project: STDCXX
>         Type: Bug
>   Components: 21. Strings
>     Versions: 4.1.2
>  Environment: All
>     Reporter: Martin Sebor
>     Assignee: Martin Sebor
>      Fix For: 4.1.3

>
> The program below aborts. According to 21.3.5.4, p16 of C++ '03, the effects of the insert member function template are "Equivalent to insert(p - begin(), basic_string(first, last))." See also http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#7.
> $ cat t.cpp && nice gmake SRCS=t.cpp && ./t
> #include <cassert>
> #include <string>
> int main ()
> {
>      std::string s ("ab");
>      s.insert (s.begin () + 1, s.data (), s.data () + s.length ());
>      assert ("aabb" == s);
> }
> aCC -c  -D_RWSTDDEBUG  -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/../../aCC-6.0-11s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include  -AA -g +d   +w +W392 +W655 +W684 +W818 +W819 +W849 +W2193 +W2236 +W2261 +W2340 +W2401 +W2487  t.cpp 
> aCC t.o -o t -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/rwtest -lrwtest -AA +nostl -Wl,+s -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib    -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib -lstd   -lm  
> Assertion failed: "aabb" == s, file t.cpp, line 10
> ABORT instruction (core dumped)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (STDCXX-25) string::insert() curruption inserting self

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/STDCXX-25?page=all ]

Martin Sebor updated STDCXX-25:
-------------------------------

    Attachment: stdcxx-25.patch

The attached patch adds a couple of overloads of string::insert for pointer and const_pointer that dispatch to an efficient insertion algorithm but fall back to a less efficient algorithm when the range being inserted is a subrange of *this.

> string::insert() curruption inserting self
> ------------------------------------------
>
>          Key: STDCXX-25
>          URL: http://issues.apache.org/jira/browse/STDCXX-25
>      Project: STDCXX
>         Type: Bug
>   Components: 21. Strings
>     Versions: 4.1.2
>  Environment: All
>     Reporter: Martin Sebor
>     Assignee: Martin Sebor
>      Fix For: 4.1.3
>  Attachments: stdcxx-25.patch
>
> The program below aborts. According to 21.3.5.4, p16 of C++ '03, the effects of the insert member function template are "Equivalent to insert(p - begin(), basic_string(first, last))." See also http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#7.
> $ cat t.cpp && nice gmake SRCS=t.cpp && ./t
> #include <cassert>
> #include <string>
> int main ()
> {
>      std::string s ("ab");
>      s.insert (s.begin () + 1, s.data (), s.data () + s.length ());
>      assert ("aabb" == s);
> }
> aCC -c  -D_RWSTDDEBUG  -D_RWSTD_USE_CONFIG -I/build/sebor/dev/stdlib/../../aCC-6.0-11s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include  -AA -g +d   +w +W392 +W655 +W684 +W818 +W819 +W849 +W2193 +W2236 +W2261 +W2340 +W2401 +W2487  t.cpp 
> aCC t.o -o t -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/rwtest -lrwtest -AA +nostl -Wl,+s -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib    -L/build/sebor/dev/stdlib/../../aCC-6.0-11s/lib -lstd   -lm  
> Assertion failed: "aabb" == s, file t.cpp, line 10
> ABORT instruction (core dumped)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira