incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Pevtsov" <Ant...@moscow.vdiweb.com>
Subject basic_string::insert (iterator p, InputIterator first, InputIterator last) on Linux, gcc-4.0.2
Date Mon, 03 Apr 2006 15:26:52 GMT

The basic_string::insert (iterator p, InputIterator first, InputIterator
last) doesn't work correctly on Linux for string str when
first = str.begin() + 1, last = str.begin() + 3.

This code illustrates the problem:

#include <rw_printf.h>  
#include <rw_char.h>    

#include <string>
#include <cstddef>

int main (void)
{
    typedef std::basic_string <char, std::char_traits<char>, 
         std::allocator<char> > TestString;

    char test[] = "abcdef";
    char exp_test[] = "bcabcdef";

    TestString s (test, 6);
    s.insert (s.begin (), s.begin () + 1, s.begin () + 3);

    rw_printf ("this (%{#*s})->insert (*this.begin (), "
               "*this.begin () + 1, *this.begin () + 3) "
               " == %{#*s}, got %{#*s}\n", 
               6, test, 8, exp_test, int (s.size ()), s.c_str ());

    return 0;
}


The output is 
this ("abcdef")->insert (*this.begin (), *this.begin () + 1, *this.begin
() + 3)  == "bcabcdef", got "baabcdef"

On Windows the output is:
this ("abcdef")->insert (*this.begin (), *this.begin () + 1, *this.begin
() + 3)  == "bcabcdef", got "bcabcdef"

Martin, could you look into this when you have a chance, please?

If you reproduce the problem I'll open the jira issue and try to
investigate the cause.


Thanks,
Anton Pevtsov

Mime
View raw message