incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Updated: (STDCXX-438) std::string::append (InputIterator, InputIterator) appending self incorrect
Date Sun, 26 Aug 2007 21:05:31 GMT

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

Martin Sebor updated STDCXX-438:
--------------------------------

         Priority: Minor  (was: Critical)
    Fix Version/s: 4.2.1

Lowering priority to Minor -- it's exceedingly unlikely that a range of InputIterators would
reference a subrange of a string object in a real program. Scheduled for 4.2.1.

> std::string::append (InputIterator, InputIterator) appending self incorrect
> ---------------------------------------------------------------------------
>
>                 Key: STDCXX-438
>                 URL: https://issues.apache.org/jira/browse/STDCXX-438
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.1.2, 4.1.3
>         Environment: all
>            Reporter: Martin Sebor
>            Priority: Minor
>             Fix For: 4.2.1
>
>
> The 21.string.append.cpp test has been failing a number of assertions for self-referential
test cases that exercise the ability to append a substring of a string into itself using the
append(InputIterator, InputIterator) member template specialization for InputIterator being
an actual Input Iterator. The program below reproduces the problem in a small isolated test
case.
> $ cat t.cpp && gmake t && ./t
> #include <cassert>
> #include <cstdlib>
> #include <cstring>
> #include <iterator>
> #include <new>
> #include <string>
> void* operator new (std::size_t n) throw (std::bad_alloc)
> {
>     void* const ptr = std::malloc (n + sizeof n);
>     std::memset (ptr, -1, n);
>     *(std::size_t*)ptr = n;
>     return (std::size_t*)ptr + 1;
> }
> void operator delete (void *ptr) throw ()
> {
>     std::memset (ptr, -1, *((std::size_t*)ptr - 1));
>     std::free ((std::size_t*)ptr - 1);
>     
> }
> struct InputIterator: std::iterator<std::input_iterator_tag, char>
> {
>     const char *p_;
>     InputIterator (const char *p): p_ (p) { }
>     char operator* () const { return *p_; }
>     InputIterator& operator++ () { return ++p_, *this; }
>     InputIterator operator++ (int) {
>         return ++p_, InputIterator (p_ - 1);
>     }
>     bool operator== (const InputIterator &rhs) const { return p_ == rhs.p_; }
> };
> int main ()
> {
>     const char s[] = "abc";
>     {
>         std::string str (s);
>         const char* p0 = s + 1;
>         const char* p1 = p0 + 1;
>         const InputIterator first (p0);
>         const InputIterator last (p1);
>         str.append (first, last);
>         assert ("abcb" == str);
>     }
>     {
>         std::string str (s);
>         const char* p0 = str.data () + 1;
>         const char* p1 = p0 + 1;
>         const InputIterator first (p0);
>         const InputIterator last (p1);
>         str.append (first, last);
>         assert ("abcb" == str);
>     }
> }
> aCC -c -I/amd/devco/sebor/stdcxx/include/ansi -I/usr/include  -D_RWSTDDEBUG   -mt -D_RWSTD_USE_CONFIG
-I/amd/devco/sebor/stdcxx/include -I/build/sebor/stdcxx-aCC-3.73-15D/include -I/amd/devco/sebor/stdcxx/tests/include
 -Aa +nostl  -g +d  +DD64 +w +W392 +W655 +W684 +W818 +W819 +W849   t.cpp
> aCC t.o -o t -L/build/sebor/stdcxx-aCC-3.73-15D/rwtest -lrwtest15D -Aa +nostl -Wl,+s
-Wl,+vnocompatwarnings   -mt +DD64 -L/build/sebor/stdcxx-aCC-3.73-15D/lib  -Wl,+b/build/sebor/stdcxx-aCC-3.73-15D/lib:/build/sebor/stdcxx-aCC-3.73-15D/rwtest
-lstd15D  -lm 
> Assertion failed: "abcb" == str, file t.cpp, line 67
> ABORT instruction (core dumped)

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


Mime
View raw message