stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject regression in string::replace()
Date Mon, 10 Mar 2008 02:50:52 GMT
When compiled with the latest trunk a number of Plum Hall tests fail
with the same error (see below). I reduced it to a small test case.
I suspect http://svn.apache.org/viewcvs?view=rev&rev=629550. Farid,
can you take a look at it whenever you have a minute?

Martin

#include <string>

template <class Iter, class T>
struct Iterator
     : public std::iterator<std::input_iterator_tag, T>
{
     Iter it;

     Iterator (Iter i): it (i) { }

     bool operator== (const Iterator &rhs) const { return it == rhs.it; }
     bool operator!= (const Iterator &rhs) const { return !(*this == rhs); }
     T operator*() const { return *it; }
     T *operator->() const { return &**this; }
     Iterator& operator++() { ++it; }
     Iterator operator++(int) {
         const Iterator tmp (*this);
         ++it;
         return tmp;
     }
};


int main ()
{
     const std::string s1;

     Iterator<std::string::const_iterator, char> i (s1.begin ());
     Iterator<std::string::const_iterator, char> j (s1.end ());
     std::string s2 (i, j);
}


Plum Hall LVS error:

$TOPDIR/include/string.cc: In member function ‘std::basic_string<_CharT, 
_Traits, _Allocator>& std::basic_string<_CharT, _Traits, 
_Allocator>::__replace_aux(__rw::__rw_debug_iter<std::basic_string<_CharT, 
_Traits, _Allocator>, typename _Allocator::pointer, typename 
_Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, 
_Traits, _Allocator>, typename _Allocator::pointer, typename 
_Allocator::pointer>, _InputIter, _InputIter) [with _InputIter = 
strict_input_iterator<__rw::__rw_debug_iter<std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >, const char*, char*>, 
char>, _CharT = char, _Traits = std::char_traits<char>, _Allocator = 
std::allocator<char>]’:
$TOPDIR/include/string.cc:517:   instantiated from 
‘std::basic_string<_CharT, _Traits, _Allocator>& 
std::basic_string<_CharT, _Traits, 
_Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, 
_Traits, _Allocator>, typename _Allocator::pointer, typename 
_Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, 
_Traits, _Allocator>, typename _Allocator::pointer, typename 
_Allocator::pointer>, _InputIter, _InputIter, void*) [with _InputIter = 
strict_input_iterator<__rw::__rw_debug_iter<std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >, const char*, char*>, 
char>, _CharT = char, _Traits = std::char_traits<char>, _Allocator = 
std::allocator<char>]’
$TOPDIR/include/string:614:   instantiated from 
‘std::basic_string<_CharT, _Traits, _Allocator>& 
std::basic_string<_CharT, _Traits, 
_Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, 
_Traits, _Allocator>, typename _Allocator::pointer, typename 
_Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, 
_Traits, _Allocator>, typename _Allocator::pointer, typename 
_Allocator::pointer>, _InputIter, _InputIter) [with _InputIter = 
strict_input_iterator<__rw::__rw_debug_iter<std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >, const char*, char*>, 
char>, _CharT = char, _Traits = std::char_traits<char>, _Allocator = 
std::allocator<char>]’
$TOPDIR/include/string:188:   instantiated from 
‘std::basic_string<_CharT, _Traits, 
_Allocator>::basic_string(_InputIter, _InputIter, const _Allocator&) 
[with _InputIter = 
strict_input_iterator<__rw::__rw_debug_iter<std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >, const char*, char*>, 
char>, _CharT = char, _Traits = std::char_traits<char>, _Allocator = 
std::allocator<char>]’
$CONFORM/t211.dir/_2131Y_151.cpp:58:   instantiated from here
$TOPDIR/include/string.cc:655: error: invalid cast of an rvalue 
expression of type ‘char’ to type ‘const char&’

Mime
View raw message